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.
This commit is contained in:
Michael Eischer 2021-11-13 20:38:49 +01:00
parent f1cfb97237
commit 50053a85d3

View file

@ -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 package rest_test
@ -65,30 +70,3 @@ func TestZeroLengthRead(t *testing.T) {
t.Fatal("Got no unexpected EOF error") 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)
}
}