2020-12-29 01:30:07 +05:30
|
|
|
package http
|
|
|
|
|
|
|
|
|
|
import (
|
2021-06-09 11:15:21 +05:30
|
|
|
"io"
|
2020-12-29 01:30:07 +05:30
|
|
|
"strings"
|
|
|
|
|
|
2023-10-17 17:44:13 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/generators"
|
2020-12-29 01:30:07 +05:30
|
|
|
"github.com/projectdiscovery/rawhttp"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// dump creates a dump of the http request in form of a byte slice
|
|
|
|
|
func dump(req *generatedRequest, reqURL string) ([]byte, error) {
|
|
|
|
|
if req.request != nil {
|
2023-01-24 22:04:52 +05:30
|
|
|
return req.request.Dump()
|
2020-12-29 01:30:07 +05:30
|
|
|
}
|
2022-05-27 18:23:07 +02:00
|
|
|
rawHttpOptions := &rawhttp.Options{CustomHeaders: req.rawRequest.UnsafeHeaders, CustomRawBytes: req.rawRequest.UnsafeRawBytes}
|
2022-08-25 13:22:08 +02:00
|
|
|
return rawhttp.DumpRequestRaw(req.rawRequest.Method, reqURL, req.rawRequest.Path, generators.ExpandMapValues(req.rawRequest.Headers), io.NopCloser(strings.NewReader(req.rawRequest.Data)), rawHttpOptions)
|
2020-12-29 01:30:07 +05:30
|
|
|
}
|