// important is "Connection" because we want a persistent
// connection, regardless of what the client sent to us.
for _, h := range hopHeaders {
- if outreq.Header.Get(h) != "" {
- outreq.Header.Del(h)
+ hv := outreq.Header.Get(h)
+ if hv == "" {
+ continue
}
+ if h == "Te" && hv == "trailers" {
+ // Issue 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)
+ continue
+ }
+ outreq.Header.Del(h)
}
if clientIP, _, err := net.SplitHostPort(req.RemoteAddr); err == nil {
if c := r.Header.Get("Connection"); c != "" {
t.Errorf("handler got Connection header value %q", c)
}
+ if c := r.Header.Get("Te"); c != "trailers" {
+ t.Errorf("handler got Te header value %q; want 'trailers'", c)
+ }
if c := r.Header.Get("Upgrade"); c != "" {
t.Errorf("handler got Upgrade header value %q", c)
}
getReq, _ := http.NewRequest("GET", frontend.URL, nil)
getReq.Host = "some-name"
getReq.Header.Set("Connection", "close")
+ getReq.Header.Set("Te", "trailers")
getReq.Header.Set("Proxy-Connection", "should be deleted")
getReq.Header.Set("Upgrade", "foo")
getReq.Close = true