mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net/http/httputil: ReverseProxy should pass on unannounced Trailers
Trailers that are not announced in the Trailer must be passed on to the downstream client. Rather than iterate over each and find missing trailer values, this re-adds all trailers to the headers if there is a disparity between the number of announced trailers and the final number. This fixes #20437 Change-Id: I867e85f45feff68616a9a9bd6f65f12d73825eb7 Reviewed-on: https://go-review.googlesource.com/43712 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
bc495c5751
commit
1611839b29
2 changed files with 18 additions and 2 deletions
|
|
@ -69,6 +69,7 @@ func TestReverseProxy(t *testing.T) {
|
|||
w.WriteHeader(backendStatus)
|
||||
w.Write([]byte(backendResponse))
|
||||
w.Header().Set("X-Trailer", "trailer_value")
|
||||
w.Header().Set(http.TrailerPrefix+"X-Unannounced-Trailer", "unannounced_trailer_value")
|
||||
}))
|
||||
defer backend.Close()
|
||||
backendURL, err := url.Parse(backend.URL)
|
||||
|
|
@ -122,6 +123,9 @@ func TestReverseProxy(t *testing.T) {
|
|||
if g, e := res.Trailer.Get("X-Trailer"), "trailer_value"; g != e {
|
||||
t.Errorf("Trailer(X-Trailer) = %q ; want %q", g, e)
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
// Test that a backend failing to be reached or one which doesn't return
|
||||
// a response results in a StatusBadGateway.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue