@@ -80,11 +80,11 @@ func (w *WebsocketProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
8080 // the final destinations.
8181 h := http.Header {}
8282 h .Add ("Origin" , req .Header .Get ("Origin" ))
83- protocols := req .Header ["Sec-WebSocket-Protocol" ]
83+ protocols := req .Header [http . CanonicalHeaderKey ( "Sec-WebSocket-Protocol" ) ]
8484 for _ , prot := range protocols {
8585 h .Add ("Sec-WebSocket-Protocol" , prot )
8686 }
87- cookies := req .Header ["Cookie" ]
87+ cookies := req .Header [http . CanonicalHeaderKey ( "Cookie" ) ]
8888 for _ , cookie := range cookies {
8989 h .Add ("Cookie" , cookie )
9090 }
@@ -114,7 +114,8 @@ func (w *WebsocketProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
114114 // Connect to the backend URL, also pass the headers we prepared above.
115115 // TODO: support multiplexing on the same backend connection instead of
116116 // opening a new TCP connection time for each request. This should be
117- // optional.
117+ // optional:
118+ // http://tools.ietf.org/html/draft-ietf-hybi-websocket-multiplexing-01
118119 connBackend , resp , err := dialer .Dial (backendURL .String (), h )
119120 if err != nil {
120121 log .Printf ("websocketproxy: couldn't dial to remote backend url %s\n " , err )
@@ -129,8 +130,10 @@ func (w *WebsocketProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
129130
130131 // Only pass those headers to the upgrader.
131132 upgradeHeader := http.Header {}
132- upgradeHeader .Add ("Sec-WebSocket-Protocol" , resp .Header .Get ("Sec-WebSocket-Protocol" ))
133- upgradeHeader .Add ("Set-Cookie" , resp .Header .Get ("Set-Cookie" ))
133+ upgradeHeader .Set ("Sec-WebSocket-Protocol" ,
134+ resp .Header .Get (http .CanonicalHeaderKey ("Sec-WebSocket-Protocol" )))
135+ upgradeHeader .Set ("Set-Cookie" ,
136+ resp .Header .Get (http .CanonicalHeaderKey ("Set-Cookie" )))
134137
135138 // Now upgrade the existing incoming request to a WebSocket connection.
136139 // Also pass the header that we gathered from the Dial handshake.
0 commit comments