ResponseRedirect constructor
Constructor.
The response will redirect the browser to addr
, which can be
a relative to the deployment URL (i.e. starts with "~/") or a real URL.
The status
must be a redirection HTTP status code.
The default status is HttpStatus.seeOther
(303).
Other commonly used values are HttpStatus.movedPermanently
(301) and
HttpStatus.movedTemporarily
(302).
The value of HttpStatus.temporaryRedirect
(307) is used when the method
is preserved. That is, GET request is redirected to a GET request
and a POST request is redirected to a POST request. Old browsers might
not support this status code.
For more information on HTTP status codes, see www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3
Implementation
ResponseRedirect(String addr, {int status = HttpStatus.seeOther}) : super() {
if (status < 300 || 399 < status) {
throw new ArgumentError.value(
status, "status", "ResponseRedirect: not a redirection HTTP status");
}
if (addr == null) {
throw new ArgumentError.notNull("ResponseRedirect.addr");
}
if (addr.isEmpty) {
throw new ArgumentError.value(
addr, "addr", "ResponseRedirect: empty string");
}
if (addr.startsWith("/")) {
_logResponse
.warning("ResponseRedirect address should start with '~/' : $addr");
}
_addr = addr;
this.status = status;
}