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
|
||||
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 {
|
||||
cancelRequest()
|
||||
failures.Add(1)
|
||||
continue
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
failures.Add(1)
|
||||
cancelRequest()
|
||||
if time.Now().Before(deadline) {
|
||||
failures.Add(1)
|
||||
}
|
||||
continue
|
||||
}
|
||||
_, readErr := io.Copy(io.Discard, response.Body)
|
||||
response.Body.Close()
|
||||
cancelRequest()
|
||||
if readErr != nil || response.StatusCode != http.StatusOK {
|
||||
failures.Add(1)
|
||||
if time.Now().Before(deadline) {
|
||||
failures.Add(1)
|
||||
}
|
||||
continue
|
||||
}
|
||||
requests.Add(1)
|
||||
|
||||
Reference in New Issue
Block a user