mirror of
https://github.com/gospider007/requests.git
synced 2025-12-24 13:57:52 +08:00
修复恐慌
This commit is contained in:
16
client.go
16
client.go
@@ -20,7 +20,7 @@ type Client struct {
|
||||
closed bool
|
||||
}
|
||||
|
||||
var defaultClient, _ = NewClient(nil)
|
||||
var defaultClient, _ = NewClient(context.TODO())
|
||||
|
||||
// New Connection Management
|
||||
func NewClient(preCtx context.Context, options ...ClientOption) (*Client, error) {
|
||||
@@ -79,13 +79,13 @@ func (obj *Client) Close() {
|
||||
obj.cnl()
|
||||
}
|
||||
|
||||
func checkRedirect(req *http.Request, via []*http.Request) error {
|
||||
ctxData := GetReqCtxData(req.Context())
|
||||
if ctxData.maxRedirect == 0 || ctxData.maxRedirect >= len(via) {
|
||||
return nil
|
||||
}
|
||||
return http.ErrUseLastResponse
|
||||
}
|
||||
// func checkRedirect(req *http.Request, via []*http.Request) error {
|
||||
// ctxData := GetReqCtxData(req.Context())
|
||||
// if ctxData.maxRedirect == 0 || ctxData.maxRedirect >= len(via) {
|
||||
// return nil
|
||||
// }
|
||||
// return http.ErrUseLastResponse
|
||||
// }
|
||||
|
||||
func (obj *Client) do(req *http.Request, option *RequestOption) (resp *http.Response, err error) {
|
||||
var redirectNum int
|
||||
|
||||
Reference in New Issue
Block a user