From 50053a85d3e4d305a9cad7ba0fa89fa880339924 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 13 Nov 2021 20:38:49 +0100 Subject: [PATCH] rest: Adjust http2 missing eof test to golang >= 1.17.3, >= 1.16.10 The missing eof with http2 when a response included a content-length header but no data, has been fixed in golang 1.17.3/1.16.10. Therefore just drop the canary test and schedule it for removal once go 1.18 is required as minimum version by restic. --- internal/backend/rest/rest_int_go114_test.go | 34 ++++---------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/internal/backend/rest/rest_int_go114_test.go b/internal/backend/rest/rest_int_go114_test.go index 036a136e1..7c040bf51 100644 --- a/internal/backend/rest/rest_int_go114_test.go +++ b/internal/backend/rest/rest_int_go114_test.go @@ -1,4 +1,9 @@ -// +build go1.14 +//go:build go1.14 && !go1.18 +// +build go1.14,!go1.18 + +// missing eof error is fixed in golang >= 1.17.3 or >= 1.16.10 +// remove the workaround from rest.go when the minimum golang version +// supported by restic reaches 1.18. package rest_test @@ -65,30 +70,3 @@ func TestZeroLengthRead(t *testing.T) { t.Fatal("Got no unexpected EOF error") } } - -func TestGolangZeroLengthRead(t *testing.T) { - // This test is intended to fail once the underlying issue has been fixed in Go - ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Length", "42") - // Now the handler fails for some reason and is unable to send data - })) - ts.EnableHTTP2 = true - ts.StartTLS() - defer ts.Close() - - res, err := ts.Client().Get(ts.URL) - if err != nil { - t.Fatal(err) - } - _, err = ioutil.ReadAll(res.Body) - defer func() { - err = res.Body.Close() - if err != nil { - t.Fatal(err) - } - }() - if err != nil { - // This should fail with an 'Unexpected EOF' error - t.Fatal(err) - } -}