3 ms·
The 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 t
by bkeroack 11y ago
The 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...