From 59133d7f0dd7cb4ec46ee7b17b1b71cff79e0309 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 18 May 2020 20:57:45 -0700 Subject: [PATCH] http2: read request in TestTransportBodyLargerThanXXX Otherwise the server can stop the connection before clientStream.writeRequestBody has a chance to see if there is any more data beyond the specified content length. Tested by adding time.Sleep(time.Millisecond) to chunkReader.Read, which caused the test to reliably fail before this change, and reliably pass afterward. Fixes golang/go#34616 Change-Id: I119bdf01bf916b2ded2c5d293655cba2596c0166 Reviewed-on: https://go-review.googlesource.com/c/net/+/234523 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- http2/transport_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http2/transport_test.go b/http2/transport_test.go index 7fe1d16d60..a17aa4a8f1 100644 --- a/http2/transport_test.go +++ b/http2/transport_test.go @@ -4516,7 +4516,7 @@ func TestTransportBodyLargerThanSpecifiedContentLength_len2(t *testing.T) { func testTransportBodyLargerThanSpecifiedContentLength(t *testing.T, body *chunkReader, contentLen int64) { st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - // Nothing. + r.Body.Read(make([]byte, 6)) }, optOnlyServer) defer st.Close()