|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
403 HTTP Status Code with Redirector action helper
Hello,
I'm having trouble with the "Redirector" action helper. If I set the the status code to 403 (forbidden), the redirector throws an exception: "Invalid redirect HTTP status code (403)" I searched the issue tracker for this and didn't find anything regarding setCode(). I am using RFC 2616 status codes: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html Error code 404 seems to work without problems. Here is some code to reproduce the error: <?php class FooAction extends Zend_Controller_Action { public function preDispatch() { $redirector = $this->_getHelper('Redirector'); $redirector->setCode(403); // throws exception $redirector->goto('index'); // never gets here } } Is there a reason why I can't use 403? If so, are there other status codes that I cannot use with the redirector? Thanks for your time :) -Hector |
|
|
Re: 403 HTTP Status Code with Redirector action helper
Nevermind, ignore me... 403
should not be used with redirects...
-Hector Hector Virgen wrote: Hello, |
|
|
Re: Re: 403 HTTP Status Code with Redirector action helperFor the enlightenment of anyone reading this later on who may not know
why, it's in section 10.3 of the linked document: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3 Only 300-level codes are acceptable for redirection (306 is currently accepted as well, but that is a bug if Redirector is HTTP/1.1-compliant). 300 Multiple Choices 301 Moved Permanently 302 Found 303 See Other 304 Not Modified 305 Use Proxy 307 Temporary Redirect In the case of a Web application (e.g., redirecting after a POST request), you should almost always use 303, which tells the browser to perform a GET on the given URL. Don't use 302 unless you mean it--browsers have been HTTP/1.1-compliant for a decade now. -Matt On Sat, May 10, 2008 12:03 pm, Hector Virgen wrote: > Nevermind, ignore me... 403 should not be used with redirects... > > -Hector > > Hector Virgen wrote: >> Hello, >> >> I'm having trouble with the "Redirector" action helper. If I set the >> the status code to 403 (forbidden), the redirector throws an exception: >> >> "Invalid redirect HTTP status code (403)" >> >> I searched the issue tracker for this and didn't find anything >> regarding setCode(). >> >> I am using RFC 2616 status codes: >> http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html >> >> Error code 404 seems to work without problems. >> >> Here is some code to reproduce the error: >> >> <?php >> >> class FooAction extends Zend_Controller_Action >> { >> public function preDispatch() >> { >> $redirector = $this->_getHelper('Redirector'); >> $redirector->setCode(403); // throws exception >> $redirector->goto('index'); // never gets here >> } >> } >> >> Is there a reason why I can't use 403? If so, are there other status >> codes that I cannot use with the redirector? Thanks for your time :) >> >> -Hector >> > |
| Free Forum Powered by Nabble | Forum Help |