Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > CGI module redirect defaults to 302 -- why?

Reply
Thread Tools

CGI module redirect defaults to 302 -- why?

 
 
Mott.Jeff@gmail.com
Guest
Posts: n/a
 
      04-29-2007
If the 302 status code is received in response to a request
other than GET or HEAD, the
user agent MUST NOT automatically redirect the request unless
it can be confirmed by the
user.
-- HTTP/1.1

For a CGI program that was requested from a POST form, the 302 message
seems to not be what I would want. But 303:

The response to the request can be found under a different URI
and SHOULD be retrieved
using a GET method on that resource. This method exists
primarily to allow the output of a
POST-activated script to redirect the user agent to a selected
resource. The new URI is not a
substitute reference for the originally requested resource.
HTTP/1.1

303 seems to be designed *exactly* for redirecting the browser after a
CGI program has run. Why then does the CGI module return a 302
response by default?

 
Reply With Quote
 
 
 
 
Mumia W.
Guest
Posts: n/a
 
      04-29-2007
On 04/29/2007 11:37 AM, wrote:
> If the 302 status code is received in response to a request
> other than GET or HEAD, the
> user agent MUST NOT automatically redirect the request unless
> it can be confirmed by the
> user.
> -- HTTP/1.1
>
> For a CGI program that was requested from a POST form, the 302 message
> seems to not be what I would want. But 303:
>
> The response to the request can be found under a different URI
> and SHOULD be retrieved
> using a GET method on that resource. This method exists
> primarily to allow the output of a
> POST-activated script to redirect the user agent to a selected
> resource. The new URI is not a
> substitute reference for the originally requested resource.
> HTTP/1.1
>
> 303 seems to be designed *exactly* for redirecting the browser after a
> CGI program has run. Why then does the CGI module return a 302
> response by default?
>


CGI forms probably respond to GET requests at least as often as they
respond to POST requests. Anyway, you are the programmer; you can
specify a different status code if you want to.

Also, if you continue reading that section (§10.3.4 of RFC2616), you see
this:

> Note: Many pre-HTTP/1.1 user agents do not understand the 303
> status. When interoperability with such clients is a concern, the
> 302 status code may be used instead, since most user agents react
> to a 302 response as described here for 303.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP my site gets a 302 temporary redirect Jeff ASP .Net 2 01-08-2010 08:44 AM
Net::HTTP::Put with 302 redirect? Chris McMahon Ruby 1 05-21-2007 09:35 PM
Want to call a custom handler that redirect and receive the http return code (302, 303 or 307) ThunderMusic ASP .Net 1 01-26-2007 04:30 PM
HTTP 302 (Response.Redirect) to mms:// URL gives error, to http:// is ok. David Morgan ASP General 1 02-24-2006 01:33 PM
Re: httpconnection class handle 302 redirect? Laszlo Zsolt Nagy Python 0 12-07-2004 05:36 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57