From 2175177497b74a1be52cc98a892e4197973c4ea6 Mon Sep 17 00:00:00 2001 From: Julien Salleyron Date: Wed, 2 Jan 2019 16:29:49 +0000 Subject: net/http/httputil: fix missing previous headers in response when switching protocol in ReverseProxy When using switching protocol, previous headers set before the reverse proxy are lost. Fixes #29407 Change-Id: Ia2b9784022d9bccef8625519ccbabbe8a276dfc0 GitHub-Last-Rev: 79bb493dcbb9b76d9d2ff9cd0854b29d634f8b73 GitHub-Pull-Request: golang/go#29408 Reviewed-on: https://go-review.googlesource.com/c/155741 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/net/http/httputil/reverseproxy.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/net/http/httputil/reverseproxy.go') diff --git a/src/net/http/httputil/reverseproxy.go b/src/net/http/httputil/reverseproxy.go index 5d07ba3d36..c13b99ff72 100644 --- a/src/net/http/httputil/reverseproxy.go +++ b/src/net/http/httputil/reverseproxy.go @@ -497,6 +497,9 @@ func (p *ReverseProxy) handleUpgradeResponse(rw http.ResponseWriter, req *http.R p.getErrorHandler()(rw, req, fmt.Errorf("backend tried to switch protocol %q when %q was requested", resUpType, reqUpType)) return } + + copyHeader(res.Header, rw.Header()) + hj, ok := rw.(http.Hijacker) if !ok { p.getErrorHandler()(rw, req, fmt.Errorf("can't switch protocols using non-Hijacker ResponseWriter type %T", rw)) -- cgit v1.3-6-g1900