1 回答

TA贡献1827条经验 获得超8个赞
http.Client提供了通过CheckRedirect成员控制它的可能性。
从上面的链接:
// CheckRedirect specifies the policy for handling redirects.
// If CheckRedirect is not nil, the client calls it before
// following an HTTP redirect. The arguments req and via are
// the upcoming request and the requests made already, oldest
// first. If CheckRedirect returns an error, the Client's Get
// method returns both the previous Response and
// CheckRedirect's error (wrapped in a url.Error) instead of
// issuing the Request req.
//
// If CheckRedirect is nil, the Client uses its default policy,
// which is to stop after 10 consecutive requests.
ct func(req *Request, via []*Request) error
- 1 回答
- 0 关注
- 407 浏览
添加回答
举报