diff --git a/connection/h2mux_test.go b/connection/h2mux_test.go index 53c28227..980a7fc8 100644 --- a/connection/h2mux_test.go +++ b/connection/h2mux_test.go @@ -119,7 +119,7 @@ func TestServeStreamHTTP(t *testing.T) { } else { assert.True(t, hasHeader(stream, ResponseMetaHeader, responseMetaHeaderOrigin)) body := make([]byte, len(test.expectedBody)) - _, err = stream.Read(body) + _, err = io.ReadFull(stream, body) require.NoError(t, err) require.Equal(t, test.expectedBody, body) } @@ -264,7 +264,7 @@ func benchmarkServeStreamHTTPSimple(b *testing.B, test testRequest) { for i := 0; i < b.N; i++ { b.StartTimer() stream, openstreamErr := edgeMux.OpenStream(ctx, headers, nil) - _, readBodyErr := stream.Read(body) + _, readBodyErr := io.ReadFull(stream, body) b.StopTimer() require.NoError(b, openstreamErr) diff --git a/connection/quic_test.go b/connection/quic_test.go index 34904d48..aa46ea67 100644 --- a/connection/quic_test.go +++ b/connection/quic_test.go @@ -226,7 +226,7 @@ func quicServer( } response := make([]byte, len(expectedResponse)) - if _, err = stream.Read(response); err != io.EOF { + if _, err = io.ReadFull(stream, response); err != io.EOF { require.NoError(t, err) } diff --git a/h2mux/h2mux_test.go b/h2mux/h2mux_test.go index 9886bedd..6b76afb3 100644 --- a/h2mux/h2mux_test.go +++ b/h2mux/h2mux_test.go @@ -796,7 +796,7 @@ func TestMultipleStreamsWithDictionaries(t *testing.T) { expectBody := strings.Replace(htmlBody, "paragraph", path, 1) + strconv.Itoa(index) responseBody := make([]byte, len(expectBody)*2) - n, err := stream.Read(responseBody) + n, err := stream.Read(responseBody) // potentially flaky because of the partial read if err != nil { errorsC <- fmt.Errorf("stream %d error from (*MuxedStream).Read: %s", stream.streamID, err) return diff --git a/quic/quic_protocol.go b/quic/quic_protocol.go index 8c7baf87..aab74669 100644 --- a/quic/quic_protocol.go +++ b/quic/quic_protocol.go @@ -205,7 +205,7 @@ func writeVersion(stream io.Writer) error { func readVersion(stream io.Reader) (string, error) { version := make([]byte, protocolVersionLength) - _, err := stream.Read(version) + _, err := io.ReadFull(stream, version) return string(version), err } diff --git a/quic/safe_stream_test.go b/quic/safe_stream_test.go index b4c096b2..ffae2538 100644 --- a/quic/safe_stream_test.go +++ b/quic/safe_stream_test.go @@ -124,7 +124,7 @@ func quicServer(t *testing.T, serverReady *sync.WaitGroup, conn net.PacketConn) func clientRoundTrip(t *testing.T, stream io.ReadWriteCloser, mustWork bool) { response := make([]byte, len(testMsg)) - _, err := stream.Read(response) + _, err := io.ReadFull(stream, response) if !mustWork { return }