summaryrefslogtreecommitdiff
path: root/modules/caddyhttp
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2021-06-04 15:21:02 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2021-06-04 15:21:16 -0600
commit2a8109468ce8520fa96e8a5139a350a1a68cbd26 (patch)
treea3d14c1ced0ee8c51b9e1f2348385f877bda9d1a /modules/caddyhttp
parent94b712009a52fd2dba6295667d359a9a3c952d31 (diff)
reverseproxy: Always remove hop-by-hop headers
See golang/go#46313 Based on https://github.com/golang/go/commit/950fa11c4cb01a145bb07eeb167d90a1846061b3
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r--modules/caddyhttp/reverseproxy/reverseproxy.go18
1 files changed, 7 insertions, 11 deletions
diff --git a/modules/caddyhttp/reverseproxy/reverseproxy.go b/modules/caddyhttp/reverseproxy/reverseproxy.go
index 671f42a..dbbf647 100644
--- a/modules/caddyhttp/reverseproxy/reverseproxy.go
+++ b/modules/caddyhttp/reverseproxy/reverseproxy.go
@@ -504,18 +504,14 @@ func (h Handler) prepareRequest(req *http.Request) error {
// Remove hop-by-hop headers to the backend. Especially
// important is "Connection" because we want a persistent
// connection, regardless of what the client sent to us.
+ // Issue golang/go#46313: don't skip if field is empty.
for _, h := range hopHeaders {
- hv := req.Header.Get(h)
- if hv == "" {
- continue
- }
- if h == "Te" && hv == "trailers" {
- // Issue golang/go#21096: tell backend applications that
- // care about trailer support that we support
- // trailers. (We do, but we don't go out of
- // our way to advertise that unless the
- // incoming client request thought it was
- // worth mentioning)
+ // Issue golang/go#21096: tell backend applications that care about trailer support
+ // that we support trailers. (We do, but we don't go out of our way to
+ // advertise that unless the incoming client request thought it was worth
+ // mentioning.)
+ if h == "Te" && httpguts.HeaderValuesContainsToken(req.Header["Te"], "trailers") {
+ req.Header.Set("Te", "trailers")
continue
}
req.Header.Del(h)