KBD

Keith Devens .com

Friday, May 16, 2008 Flag waving
I have the strength of a bear... that has the strength of two bears! – Sealab 2021
← Wolfram on DarwinXML-RPC validation suite →

Daily link icon Tuesday, June 11, 2002

GET after POST revisited

Advogato: Designing server-side applications in PHP. The main reason I'm blogging this is because of dan's comments that GET after POST isn't actually supposed to work, which is news to me:

  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, since this might
  change the conditions under which the request was issued.

    Note: When automatically redirecting a POST request after receiving
    a 302 status code, some existing HTTP/1.0 user agents will
    erroneously change it into a GET request.

Dan's comments:

By the time they got to RFC 2616, they apparently realised that "some existing HTTP/1.0" user agents includes basically every useful browser out there, so they changed the wording to "most existing user agent[s]" and introduced new responses 303 (allow redirect from POST, always using GET) and 307 (don't redirect from POST, just like they originally intended 302 to have done). So you probably should be using a 303 instead of a 302 for this purpose. If your users know what it is. How do you test that? I've no idea: it seems unlikely that simply checking the HTTP request version for 1.1ness is going to be particularly accurate. Frankly I'd be a lot happier if they'd just repurposed 302 instead of creating 303, but we have to hope there was some good reason for not following existing practice there.

I have to do some experimenting, but for now, here's the relevant section in the HTTP RFC.

← Wolfram on DarwinXML-RPC validation suite →

Comments XML gif

M. Bean (http://www.yaysoft.com/) wrote:

"When automatically redirecting a POST request after receiving a 302 status code, some existing HTTP/1.0 user agents will erroneously change it into a GET request."

Heh... I had this exact problem when I was writing up my XML-RPC code and I had accidentally left the trailing slash off of the domain name... it kept converting my request to GET and messing everything up, I didn't notice until I broke down and installed Ethereal and nabbed the packets for myself.

∴ M. Bean | 11-Jun-2002 5:43pm est | http://www.yaysoft.com/ | #474

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

May 2008
SunMonTueWedThuFriSat
 123
45678910
11121314151617
18192021222324
25262728293031



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 2 posts

Recent comments XML

new⇒Maps of Iraq

my husband is in Scania too..he​says it's not too bad..he's been at​worse...

Cristy: May 16, 3:54pm

"IMDB for music"

IMDB for Music? It looks to be a​couple of years old...​http://MusicTell.co...

Ken Empie: May 14, 9:57pm

Generated in about 0.204s.

(Used 8 db queries)