Ensure keep-alive is not used in http_response input.
Using Keep-Alive would change the timing for already established connections. Previous to this commit, Keep-Alive worked only when using a response_string_match due to failure to close the request body.
This commit is contained in:
parent
a1446a60f7
commit
17d883c602
|
@ -92,7 +92,8 @@ func (h *HTTPResponse) createHttpClient() (*http.Client, error) {
|
||||||
}
|
}
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
TLSClientConfig: tlsCfg,
|
DisableKeepAlives: true,
|
||||||
|
TLSClientConfig: tlsCfg,
|
||||||
},
|
},
|
||||||
Timeout: h.ResponseTimeout.Duration,
|
Timeout: h.ResponseTimeout.Duration,
|
||||||
}
|
}
|
||||||
|
@ -140,6 +141,11 @@ func (h *HTTPResponse) httpGather() (map[string]interface{}, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
io.Copy(ioutil.Discard, resp.Body)
|
||||||
|
resp.Body.Close()
|
||||||
|
}()
|
||||||
|
|
||||||
fields["response_time"] = time.Since(start).Seconds()
|
fields["response_time"] = time.Since(start).Seconds()
|
||||||
fields["http_response_code"] = resp.StatusCode
|
fields["http_response_code"] = resp.StatusCode
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue