fix: keep HTTP2 soak context through response body
This commit is contained in:
@@ -91,20 +91,28 @@ func TestTLSSoak(t *testing.T) {
|
|||||||
method = http.MethodPost
|
method = http.MethodPost
|
||||||
body = &repeatingReader{remaining: 64 << 10}
|
body = &repeatingReader{remaining: 64 << 10}
|
||||||
}
|
}
|
||||||
request, err := http.NewRequestWithContext(context.Background(), method, "https://"+listener.Addr().String()+path, body)
|
requestContext, cancelRequest := context.WithTimeout(context.Background(), 2*time.Second)
|
||||||
|
request, err := http.NewRequestWithContext(requestContext, method, "https://"+listener.Addr().String()+path, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
cancelRequest()
|
||||||
failures.Add(1)
|
failures.Add(1)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
response, err := client.Do(request)
|
response, err := client.Do(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
cancelRequest()
|
||||||
|
if time.Now().Before(deadline) {
|
||||||
failures.Add(1)
|
failures.Add(1)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
_, readErr := io.Copy(io.Discard, response.Body)
|
_, readErr := io.Copy(io.Discard, response.Body)
|
||||||
response.Body.Close()
|
response.Body.Close()
|
||||||
|
cancelRequest()
|
||||||
if readErr != nil || response.StatusCode != http.StatusOK {
|
if readErr != nil || response.StatusCode != http.StatusOK {
|
||||||
|
if time.Now().Before(deadline) {
|
||||||
failures.Add(1)
|
failures.Add(1)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
requests.Add(1)
|
requests.Add(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user