newhttp: support websocket

This commit is contained in:
fatedier
2018-01-23 01:29:52 +08:00
parent 3f64d73ea9
commit cf9193a429
2 changed files with 64 additions and 0 deletions

View File

@@ -79,6 +79,11 @@ func NewHttpReverseProxy() *HttpReverseProxy {
return rp.CreateConnection(host, url)
},
},
WebSocketDialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
url := ctx.Value("url").(string)
host := getHostFromAddr(ctx.Value("host").(string))
return rp.CreateConnection(host, url)
},
BufferPool: newWrapPool(),
ErrorLog: log.New(newWrapLogger(), "", 0),
}