mirror of
https://github.com/projectdiscovery/httpx.git
synced 2024-09-11 17:46:08 +03:00
Fixed bodyclose issues
This commit is contained in:
parent
e9aa081544
commit
c68436373f
@ -112,19 +112,14 @@ func New(options *Options) (*HTTPX, error) {
|
||||
|
||||
// Do http request
|
||||
func (h *HTTPX) Do(req *retryablehttp.Request) (*Response, error) {
|
||||
var (
|
||||
httpresp *http.Response
|
||||
err error
|
||||
)
|
||||
if h.Options.Unsafe {
|
||||
httpresp, err = h.doUnsafe(req)
|
||||
} else {
|
||||
httpresp, err = h.client.Do(req)
|
||||
}
|
||||
httpresp, err := h.getResponse(req)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer httpresp.Body.Close()
|
||||
|
||||
var resp Response
|
||||
resp.Headers = httpresp.Header.Clone()
|
||||
|
||||
@ -177,7 +172,16 @@ type RequestOverride struct {
|
||||
URIPath string
|
||||
}
|
||||
|
||||
// Do http request
|
||||
// getResponse returns response from safe / unsafe request
|
||||
func (h *HTTPX) getResponse(req *retryablehttp.Request) (*http.Response, error) {
|
||||
if h.Options.Unsafe {
|
||||
return h.doUnsafe(req)
|
||||
}
|
||||
|
||||
return h.client.Do(req)
|
||||
}
|
||||
|
||||
// doUnsafe does an unsafe http request
|
||||
func (h *HTTPX) doUnsafe(req *retryablehttp.Request) (*http.Response, error) {
|
||||
method := req.Method
|
||||
headers := req.Header
|
||||
|
Loading…
Reference in New Issue
Block a user