Commit 479c47e4 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http: maybe deflake TestCancelRequestMidBody_h2 on linux-noopt builder

This might deflake it. Or it'll at least give us more debugging clues.

Fixes #13626 maybe

Change-Id: Ie8cd0375d60dad033ec6a64830a90e7b9152a3d9
Reviewed-on: https://go-review.googlesource.com/17825Reviewed-by: 's avatarAustin Clements <austin@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
parent 99fb1919
......@@ -430,7 +430,6 @@ func testCancelRequestMidBody(t *testing.T, h2 bool) {
didFlush <- true
<-unblock
io.WriteString(w, ", world.")
<-unblock
}))
defer cst.close()
defer close(unblock)
......@@ -445,11 +444,22 @@ func testCancelRequestMidBody(t *testing.T, h2 bool) {
}
defer res.Body.Close()
<-didFlush
// Read a bit before we cancel. (Issue 13626)
// We should have "Hello" at least sitting there.
firstRead := make([]byte, 10)
n, err := res.Body.Read(firstRead)
if err != nil {
t.Fatal(err)
}
firstRead = firstRead[:n]
close(cancel)
slurp, err := ioutil.ReadAll(res.Body)
if string(slurp) != "Hello" {
t.Errorf("Read %q; want Hello", slurp)
rest, err := ioutil.ReadAll(res.Body)
all := string(firstRead) + string(rest)
if all != "Hello" {
t.Errorf("Read %q (%q + %q); want Hello", all, firstRead, rest)
}
if !reflect.DeepEqual(err, ExportErrRequestCanceled) {
t.Errorf("ReadAll error = %v; want %v", err, ExportErrRequestCanceled)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment