@marcel91200 / caddy Mirror · read-only / commits / 2a810946
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

reverseproxy: Always remove hop-by-hop headers

See golang/go#46313 Based on https://github.com/golang/go/commit/950fa11c4cb01a145bb07eeb167d90a1846061b3

Matthew Holt committed Jun 4, 2021 at 15:21 UTC 2a8109468ce8520fa96e8a5139a350a1a68cbd26
1 file changed +7 -11
modules/caddyhttp/reverseproxy/reverseproxy.go
+7 -11
@@ -504,18 +504,14 @@ func (h Handler) prepareRequest(req *http.Request) error {
504 // Remove hop-by-hop headers to the backend. Especially
505 // important is "Connection" because we want a persistent
506 // connection, regardless of what the client sent to us.
507 + // Issue golang/go#46313: don't skip if field is empty.
508 for _, h := range hopHeaders {
508 - hv := req.Header.Get(h)
509 - if hv == "" {
510 - continue
511 - }
512 - if h == "Te" && hv == "trailers" {
513 - // Issue golang/go#21096: tell backend applications that
514 - // care about trailer support that we support
515 - // trailers. (We do, but we don't go out of
516 - // our way to advertise that unless the
517 - // incoming client request thought it was
518 - // worth mentioning)
509 + // Issue golang/go#21096: tell backend applications that care about trailer support
510 + // that we support trailers. (We do, but we don't go out of our way to
511 + // advertise that unless the incoming client request thought it was worth
512 + // mentioning.)
513 + if h == "Te" && httpguts.HeaderValuesContainsToken(req.Header["Te"], "trailers") {
514 + req.Header.Set("Te", "trailers")
515 continue
516 }
517 req.Header.Del(h)