Merge pull request #1839 from projectdiscovery/issue-1833-scan-bug

Improving body dump logic for HTTP requests
dev
Sandeep Singh 2022-04-13 16:44:12 +05:30 committed by GitHub
commit 51bca65236
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -117,15 +117,17 @@ func dump(req *generatedRequest, reqURL string) ([]byte, error) {
if req.request != nil {
// Create a copy on the fly of the request body - ignore errors
bodyBytes, _ := req.request.BodyBytes()
var dumpBody bool
if len(bodyBytes) > 0 {
req.request.Request.ContentLength = int64(len(bodyBytes))
req.request.Request.Body = ioutil.NopCloser(bytes.NewReader(bodyBytes))
} else {
req.request.Request.ContentLength = 0
req.request.Request.Body = nil
delete(req.request.Request.Header, "Content-length")
}
dumpBytes, err := httputil.DumpRequestOut(req.request.Request, true)
dumpBytes, err := httputil.DumpRequestOut(req.request.Request, dumpBody)
if err != nil {
return nil, err
}