我想对 POST 请求使用相同的正文进行重定向。
来自 GO 来源 (client.go)
func redirectBehavior(reqMethod string, resp *Response, ireq *Request) (redirectMethod string, shouldRedirect, includeBody bool) {
switch resp.StatusCode {
case 301, 302, 303:
redirectMethod = reqMethod
shouldRedirect = true
includeBody = false
// RFC 2616 allowed automatic redirection only with GET and
// HEAD requests. RFC 7231 lifts this restriction, but we still
// restrict other methods to GET to maintain compatibility.
// See Issue 18570.
Run Code Online (Sandbox Code Playgroud)
但有时服务器会为 POST 请求返回 302 Redirect,这意味着我需要将相同的正文发送到另一个位置。
在这种情况下我该怎么办?
func FollowRedirectForPost() {
client …Run Code Online (Sandbox Code Playgroud)