mirror of
https://github.com/golang/go
synced 2024-11-22 05:04:40 -07:00
net/http/httputil: close res body in test
Change-Id: Ic57c93a8d8413fe4985bc430255b6db90e11b70c
GitHub-Last-Rev: 25db6644c6
GitHub-Pull-Request: golang/go#68397
Reviewed-on: https://go-review.googlesource.com/c/go/+/597936
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
This commit is contained in:
parent
d3c82937e9
commit
8b32ce586d
@ -137,6 +137,7 @@ func TestReverseProxy(t *testing.T) {
|
||||
if g, e := res.Trailer.Get("X-Unannounced-Trailer"), "unannounced_trailer_value"; g != e {
|
||||
t.Errorf("Trailer(X-Unannounced-Trailer) = %q ; want %q", g, e)
|
||||
}
|
||||
res.Body.Close()
|
||||
|
||||
// Test that a backend failing to be reached or one which doesn't return
|
||||
// a response results in a StatusBadGateway.
|
||||
@ -328,6 +329,7 @@ func TestXForwardedFor(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Get: %v", err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if g, e := res.StatusCode, backendStatus; g != e {
|
||||
t.Errorf("got res.StatusCode %d; expected %d", g, e)
|
||||
}
|
||||
@ -801,6 +803,7 @@ func TestReverseProxy_Post(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Do: %v", err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if g, e := res.StatusCode, backendStatus; g != e {
|
||||
t.Errorf("got res.StatusCode %d; expected %d", g, e)
|
||||
}
|
||||
@ -1571,7 +1574,7 @@ func TestUnannouncedTrailer(t *testing.T) {
|
||||
}
|
||||
|
||||
io.ReadAll(res.Body)
|
||||
|
||||
res.Body.Close()
|
||||
if g, w := res.Trailer.Get("X-Unannounced-Trailer"), "unannounced_trailer_value"; g != w {
|
||||
t.Errorf("Trailer(X-Unannounced-Trailer) = %q; want %q", g, w)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user