mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-29 04:19:57 +00:00
TUN-3853: Respond with ws headers from the origin service rather than generating our own
This commit is contained in:

committed by
Nuno Diegues

parent
9c298e4851
commit
ed57ee64e8
@@ -166,20 +166,22 @@ func (p *proxy) proxyConnection(
|
||||
sourceConnectionType connection.Type,
|
||||
connectionProxy ingress.StreamBasedOriginProxy,
|
||||
) (*http.Response, error) {
|
||||
originConn, err := connectionProxy.EstablishConnection(req)
|
||||
originConn, connectionResp, err := connectionProxy.EstablishConnection(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var eyeballConn io.ReadWriter = w
|
||||
respHeader := http.Header{}
|
||||
if connectionResp != nil {
|
||||
respHeader = connectionResp.Header
|
||||
}
|
||||
if sourceConnectionType == connection.TypeWebsocket {
|
||||
wsReadWriter := websocket.NewConn(serveCtx, w, p.log)
|
||||
// If cloudflared <-> origin is not websocket, we need to decode TCP data out of WS frames
|
||||
if originConn.Type() != sourceConnectionType {
|
||||
eyeballConn = wsReadWriter
|
||||
}
|
||||
respHeader = websocket.NewResponseHeader(req)
|
||||
}
|
||||
status := http.StatusSwitchingProtocols
|
||||
resp := &http.Response{
|
||||
|
Reference in New Issue
Block a user