3 ms·
I'd be interested in the use case where the difference between 302 and 307: the user agent MUST NOT change the request method if it performs an automatic r
by oneeyedpigeon 11y ago
I'd be interested in the use case where the difference between 302 and 307:
the user agent MUST NOT change the request method if it performs
an automatic redirection to that URI
is significant. Do user agents switch from POST to GET when following a 302?
- ErrantX 11y agohttps://en.wikipedia.org/wiki/HTTP_302 https://en.wikipedia.org/wiki/HTTP_302 Most browsers mis-implement 302; hence 303 (must change to GET) and 307 (must persist request method) were added to make the options explicit. Of course, just because a standard now exists....
- bkeroack 11y agoThe Go standard library HTTP client (net/http) changes POST/PUT redirects to GET[1] and it's super annoying. EDIT: Here's the rationale (from [2]): "I think the underlying principle of the matter is that if the client is going to resend the POST request body data, then RFC 2616 wants clients to get the user's consent. The trouble is that most client implementations did not resend the POST data when following 301 or 302 redirects. So the principle of getting user consent doesn't really apply. RFC 7231 (HTTP/1.1 June 2014) changes this. It ratifies the common behavior of 301 and 302 (to not re-POST), and in doing so it leaves it up to the client to determine when it is safe to automatically redirect." 1. https://github.com/golang/go/blob/master/src/net/http/client.go#L362-L364 https://github.com/golang/go/blob/master/src/net/http/client... 2. https://github.com/golang/go/issues/9348#issuecomment-86790338 https://github.com/golang/go/issues/9348#issuecomment-867903...