diff --git a/forward/fwd.go b/forward/fwd.go index 707d2f9d..18875cc6 100644 --- a/forward/fwd.go +++ b/forward/fwd.go @@ -10,7 +10,6 @@ import ( "net/http" "net/url" "os" - "strconv" "strings" "time" @@ -168,8 +167,10 @@ func (f *httpForwarder) serveHTTP(w http.ResponseWriter, req *http.Request, ctx } utils.CopyHeaders(w.Header(), response.Header) + // Remove hop-by-hop headers. + utils.RemoveHeaders(w.Header(), HopHeaders...) w.WriteHeader(response.StatusCode) - written, err := io.Copy(w, response.Body) + _, err = io.Copy(w, response.Body) defer response.Body.Close() if err != nil { @@ -177,10 +178,6 @@ func (f *httpForwarder) serveHTTP(w http.ResponseWriter, req *http.Request, ctx ctx.errHandler.ServeHTTP(w, req, err) return } - - if written != 0 { - w.Header().Set(ContentLength, strconv.FormatInt(written, 10)) - } } // copyRequest makes a copy of the specified request to be sent using the configured