mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 20:05:27 +00:00
22 lines
637 B
Go
22 lines
637 B
Go
package requests
|
|
|
|
import (
|
|
"bytes"
|
|
"io/ioutil"
|
|
"net/http/httputil"
|
|
"strings"
|
|
|
|
"github.com/projectdiscovery/rawhttp"
|
|
)
|
|
|
|
func Dump(req *HTTPRequest, reqURL string) ([]byte, error) {
|
|
if req.Request != nil {
|
|
// Create a copy on the fly of the request body - ignore errors
|
|
bodyBytes, _ := req.Request.BodyBytes()
|
|
req.Request.Request.Body = ioutil.NopCloser(bytes.NewReader(bodyBytes))
|
|
return httputil.DumpRequest(req.Request.Request, true)
|
|
}
|
|
|
|
return rawhttp.DumpRequestRaw(req.RawRequest.Method, reqURL, req.RawRequest.Path, ExpandMapValues(req.RawRequest.Headers), ioutil.NopCloser(strings.NewReader(req.RawRequest.Data)))
|
|
}
|