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.
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)
}
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)
}
}
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)
}