@@ -11,14 +11,11 @@ import (
11
11
)
12
12
13
13
var (
14
- // DefaultUpgrader specifies the paramaters for upgrading an HTTP connection to
15
- // a WebSocket connection.
14
+ // DefaultUpgrader specifies the paramaters for upgrading an HTTP
15
+ // connection to a WebSocket connection.
16
16
DefaultUpgrader = & websocket.Upgrader {
17
- ReadBufferSize : 4096 ,
18
- WriteBufferSize : 4096 ,
19
- CheckOrigin : func (r * http.Request ) bool {
20
- return true
21
- },
17
+ ReadBufferSize : 1024 ,
18
+ WriteBufferSize : 1024 ,
22
19
}
23
20
24
21
// DefaultDialer is a dialer with all fields set to the default zero values.
@@ -45,7 +42,7 @@ type WebsocketProxy struct {
45
42
// request to the given target.
46
43
func ProxyHandler (target * url.URL ) http.Handler {
47
44
return http .HandlerFunc (func (rw http.ResponseWriter , req * http.Request ) {
48
- NewProxy (target ).ServerHTTP (rw , req )
45
+ NewProxy (target ).ServeHTTP (rw , req )
49
46
})
50
47
}
51
48
@@ -56,8 +53,8 @@ func NewProxy(target *url.URL) *WebsocketProxy {
56
53
return & WebsocketProxy {Backend : backend }
57
54
}
58
55
59
- // ServerHTTP implements the http.Handler that proxies WebSocket connections.
60
- func (w * WebsocketProxy ) ServerHTTP (rw http.ResponseWriter , req * http.Request ) {
56
+ // ServeHTTP implements the http.Handler that proxies WebSocket connections.
57
+ func (w * WebsocketProxy ) ServeHTTP (rw http.ResponseWriter , req * http.Request ) {
61
58
upgrader := w .Upgrader
62
59
if w .Upgrader == nil {
63
60
upgrader = DefaultUpgrader
@@ -92,5 +89,6 @@ func (w *WebsocketProxy) ServerHTTP(rw http.ResponseWriter, req *http.Request) {
92
89
93
90
go cp (connBackend .UnderlyingConn (), connPub .UnderlyingConn ())
94
91
go cp (connPub .UnderlyingConn (), connBackend .UnderlyingConn ())
95
- <- errc
92
+ err = <- errc
93
+ log .Println ("websocketproxy: connection ended %s" , err )
96
94
}
0 commit comments