mirror of https://github.com/daffainfo/nuclei.git
Merge branch 'dev' of https://github.com/projectdiscovery/nuclei into dev
commit
d33f6eb502
|
@ -349,7 +349,9 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, previ
|
|||
return err
|
||||
}
|
||||
defer func() {
|
||||
if resp.StatusCode != http.StatusSwitchingProtocols {
|
||||
_, _ = io.CopyN(ioutil.Discard, resp.Body, drainReqSize)
|
||||
}
|
||||
resp.Body.Close()
|
||||
}()
|
||||
|
||||
|
@ -363,13 +365,16 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, previ
|
|||
return errors.Wrap(err, "could not dump http response")
|
||||
}
|
||||
|
||||
var data, redirectedResponse []byte
|
||||
// If the status code is HTTP 101, we should not proceed with reading body.
|
||||
if resp.StatusCode != http.StatusSwitchingProtocols {
|
||||
var bodyReader io.Reader
|
||||
if r.MaxSize != 0 {
|
||||
bodyReader = io.LimitReader(resp.Body, int64(r.MaxSize))
|
||||
} else {
|
||||
bodyReader = resp.Body
|
||||
}
|
||||
data, err := ioutil.ReadAll(bodyReader)
|
||||
data, err = ioutil.ReadAll(bodyReader)
|
||||
if err != nil {
|
||||
// Ignore body read due to server misconfiguration errors
|
||||
if stringsutil.ContainsAny(err.Error(), "gzip: invalid header") {
|
||||
|
@ -380,10 +385,13 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, previ
|
|||
}
|
||||
resp.Body.Close()
|
||||
|
||||
redirectedResponse, err := dumpResponseWithRedirectChain(resp, data)
|
||||
redirectedResponse, err = dumpResponseWithRedirectChain(resp, data)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not read http response with redirect chain")
|
||||
}
|
||||
} else {
|
||||
redirectedResponse = dumpedResponseHeaders
|
||||
}
|
||||
|
||||
// net/http doesn't automatically decompress the response body if an
|
||||
// encoding has been specified by the user in the request so in case we have to
|
||||
|
|
Loading…
Reference in New Issue