p.Director(outreq)
outreq.Close = false
- // Remove hop-by-hop headers listed in the "Connection" header.
- // See RFC 2616, section 14.10.
- if c := outreq.Header.Get("Connection"); c != "" {
- for _, f := range strings.Split(c, ",") {
- if f = strings.TrimSpace(f); f != "" {
- outreq.Header.Del(f)
- }
- }
- }
+ removeConnectionHeaders(outreq.Header)
// Remove hop-by-hop headers to the backend. Especially
// important is "Connection" because we want a persistent
return
}
- // Remove hop-by-hop headers listed in the
- // "Connection" header of the response.
- if c := res.Header.Get("Connection"); c != "" {
- for _, f := range strings.Split(c, ",") {
- if f = strings.TrimSpace(f); f != "" {
- res.Header.Del(f)
- }
- }
- }
+ removeConnectionHeaders(res.Header)
for _, h := range hopHeaders {
res.Header.Del(h)
}
}
+// removeConnectionHeaders removes hop-by-hop headers listed in the "Connection" header of h.
+// See RFC 2616, section 14.10.
+func removeConnectionHeaders(h http.Header) {
+ if c := h.Get("Connection"); c != "" {
+ for _, f := range strings.Split(c, ",") {
+ if f = strings.TrimSpace(f); f != "" {
+ h.Del(f)
+ }
+ }
+ }
+}
+
func (p *ReverseProxy) copyResponse(dst io.Writer, src io.Reader) {
if p.FlushInterval != 0 {
if wf, ok := dst.(writeFlusher); ok {