mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 06:45:25 +00:00
parent
f8a4cf50c6
commit
8720e4f863
@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/projectdiscovery/rawhttp"
|
||||
urlutil "github.com/projectdiscovery/utils/url"
|
||||
)
|
||||
|
||||
// WithCustomTimeout is a configuration for custom timeout
|
||||
@ -39,7 +40,27 @@ func SendRawRequest(client *rawhttp.Client, opts *RawHttpRequestOpts) (*http.Res
|
||||
// this error is caused when rawhttp client sends a corrupted or malformed request packet to server
|
||||
// some servers may attempt gracefully shutdown but most will just abruptly close the connection which results
|
||||
// in a connection reset by peer error and this can be safely assumed as 400 Bad Request in terms of normal http flow
|
||||
req, _ := http.NewRequest(opts.Method, opts.URL, opts.Body)
|
||||
req, reqErr := http.NewRequest(opts.Method, opts.URL, opts.Body)
|
||||
if reqErr != nil {
|
||||
// failed to build new request mostly because of invalid url or body
|
||||
// try again or else return urlErr
|
||||
parsed, urlErr := urlutil.ParseAbsoluteURL(opts.URL, true)
|
||||
if urlErr != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, reqErr = http.NewRequest(opts.Method, parsed.Host, opts.Body)
|
||||
if reqErr != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.URL = parsed.URL
|
||||
req.Header = opts.Headers
|
||||
}
|
||||
|
||||
// if req is still nil, return error
|
||||
if req == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.Header = opts.Headers
|
||||
resp = &http.Response{
|
||||
Request: req,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user