Adding support for timeout in rawhttp

This commit is contained in:
mzack 2021-06-25 08:16:54 +02:00
parent 4764a34224
commit 713433026d
2 changed files with 5 additions and 3 deletions

View File

@ -111,7 +111,7 @@ func (r *Request) Compile(options *protocols.ExecuterOptions) error {
r.Raw[i] = strings.ReplaceAll(raw, "\n", "\r\n") r.Raw[i] = strings.ReplaceAll(raw, "\n", "\r\n")
} }
} }
r.rawhttpClient = httpclientpool.GetRawHTTP() r.rawhttpClient = httpclientpool.GetRawHTTP(options.Options)
} }
if len(r.Matchers) > 0 || len(r.Extractors) > 0 { if len(r.Matchers) > 0 || len(r.Extractors) > 0 {
compiled := &r.Operators compiled := &r.Operators

View File

@ -79,9 +79,11 @@ func (c *Configuration) Hash() string {
} }
// GetRawHTTP returns the rawhttp request client // GetRawHTTP returns the rawhttp request client
func GetRawHTTP() *rawhttp.Client { func GetRawHTTP(options *types.Options) *rawhttp.Client {
if rawhttpClient == nil { if rawhttpClient == nil {
rawhttpClient = rawhttp.NewClient(rawhttp.DefaultOptions) rawhttpOptions := rawhttp.DefaultOptions
rawhttpOptions.Timeout = time.Duration(options.Timeout) * time.Second
rawhttpClient = rawhttp.NewClient(rawhttpOptions)
} }
return rawhttpClient return rawhttpClient
} }