@@ -80,11 +80,11 @@ func (w *WebsocketProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
80
80
// the final destinations.
81
81
h := http.Header {}
82
82
h .Add ("Origin" , req .Header .Get ("Origin" ))
83
- protocols := req .Header ["Sec-WebSocket-Protocol" ]
83
+ protocols := req .Header [http . CanonicalHeaderKey ( "Sec-WebSocket-Protocol" ) ]
84
84
for _ , prot := range protocols {
85
85
h .Add ("Sec-WebSocket-Protocol" , prot )
86
86
}
87
- cookies := req .Header ["Cookie" ]
87
+ cookies := req .Header [http . CanonicalHeaderKey ( "Cookie" ) ]
88
88
for _ , cookie := range cookies {
89
89
h .Add ("Cookie" , cookie )
90
90
}
@@ -114,7 +114,8 @@ func (w *WebsocketProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
114
114
// Connect to the backend URL, also pass the headers we prepared above.
115
115
// TODO: support multiplexing on the same backend connection instead of
116
116
// 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
118
119
connBackend , resp , err := dialer .Dial (backendURL .String (), h )
119
120
if err != nil {
120
121
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) {
129
130
130
131
// Only pass those headers to the upgrader.
131
132
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" )))
134
137
135
138
// Now upgrade the existing incoming request to a WebSocket connection.
136
139
// Also pass the header that we gathered from the Dial handshake.
0 commit comments