@@ -63,6 +63,8 @@ func (w *WebsocketProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
63
63
dialer = DefaultDialer
64
64
}
65
65
66
+ // TODO: Also consider adding x-fowarded-for and x-forwarded-proto headers.
67
+
66
68
// Pass headers from the incoming request to the dialer to forward them to
67
69
// the final destinations.
68
70
h := http.Header {}
@@ -90,13 +92,13 @@ func (w *WebsocketProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
90
92
}
91
93
92
94
// Only pass those headers to the upgrader.
93
- respHeader := http.Header {}
94
- resp . Header .Add ("Sec-WebSocket-Protocol" , resp .Header .Get ("Sec-WebSocket-Protocol" ))
95
- resp . Header .Add ("Set-Cookie" , resp .Header .Get ("Set-Cookie" ))
95
+ upgradeHeader := http.Header {}
96
+ upgradeHeader .Add ("Sec-WebSocket-Protocol" , resp .Header .Get ("Sec-WebSocket-Protocol" ))
97
+ upgradeHeader .Add ("Set-Cookie" , resp .Header .Get ("Set-Cookie" ))
96
98
97
99
// Now upgrade the existing incoming request to a WebSocket connection.
98
- // Also pass the responseHeader that we gathered from the Dial handshake.
99
- connPub , err := upgrader .Upgrade (rw , req , respHeader )
100
+ // Also pass the header that we gathered from the Dial handshake.
101
+ connPub , err := upgrader .Upgrade (rw , req , upgradeHeader )
100
102
if err != nil {
101
103
log .Printf ("websocketproxy: couldn't upgrade %s\n " , err )
102
104
return
@@ -109,7 +111,7 @@ func (w *WebsocketProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
109
111
errc <- err
110
112
}
111
113
112
- // Start our proxy now, after we setup everything .
114
+ // Start our proxy now, everything is ready.. .
113
115
go cp (connBackend .UnderlyingConn (), connPub .UnderlyingConn ())
114
116
go cp (connPub .UnderlyingConn (), connBackend .UnderlyingConn ())
115
117
<- errc
0 commit comments