Skip to content

Commit

Permalink
reverseproxy: Always remove hop-by-hop headers
Browse files Browse the repository at this point in the history
  • Loading branch information
mholt committed Jun 4, 2021
1 parent 94b7120 commit 2a81094
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions modules/caddyhttp/reverseproxy/reverseproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2a81094

Please sign in to comment.