update
parent
7ead69e1b6
commit
86b2a17868
|
@ -232,8 +232,10 @@ func (r *Request) Do(method, rawUrl string) (*Response, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.StatusCode != http.StatusOK {
|
if r.httpClient.config.noCheckStatus == false {
|
||||||
return nil, fmt.Errorf("status code err: %d (%s)", res.StatusCode, body)
|
if res.StatusCode != http.StatusOK {
|
||||||
|
return nil, fmt.Errorf("status code err: %d (%s)", res.StatusCode, body)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := &Response{
|
resp := &Response{
|
||||||
|
|
|
@ -7,10 +7,11 @@ import (
|
||||||
|
|
||||||
type (
|
type (
|
||||||
Config struct {
|
Config struct {
|
||||||
timeout time.Duration
|
timeout time.Duration
|
||||||
client *http.Client
|
client *http.Client
|
||||||
transport *http.Transport
|
transport *http.Transport
|
||||||
redirectFn func(req *http.Request, via []*http.Request) error
|
redirectFn func(req *http.Request, via []*http.Request) error
|
||||||
|
noCheckStatus bool
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigOpt func(c *Config)
|
ConfigOpt func(c *Config)
|
||||||
|
@ -47,3 +48,9 @@ func WithNoRedirect() ConfigOpt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithNoCheckStatus(v bool) ConfigOpt {
|
||||||
|
return func(c *Config) {
|
||||||
|
c.noCheckStatus = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue