Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/requestHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ function fetchRemoteResponse(protocol, options, reqData, config) {
function getWsReqInfo(wsReq) {
const headers = wsReq.headers || {};
const host = headers.host;
const wsProtocol = headers['sec-websocket-protocol'] || '';
const hostName = host.split(':')[0];
const port = host.split(':')[1];

Expand Down Expand Up @@ -248,7 +249,8 @@ function getWsReqInfo(wsReq) {
hostName: hostName,
port: port,
path: path,
protocol: isEncript ? 'wss' : 'ws'
protocol: isEncript ? 'wss' : 'ws',
wsProtocol: wsProtocol
};
}
/**
Expand Down Expand Up @@ -712,7 +714,7 @@ function getWsHandler(userRule, recorder, wsClient, wsReq) {
const serverInfo = getWsReqInfo(wsReq);
const serverInfoPort = serverInfo.port ? `:${serverInfo.port}` : '';
const wsUrl = `${serverInfo.protocol}://${serverInfo.hostName}${serverInfoPort}${serverInfo.path}`;
const proxyWs = new WebSocket(wsUrl, '', {
const proxyWs = new WebSocket(wsUrl, serverInfo.wsProtocol, {
rejectUnauthorized: !self.dangerouslyIgnoreUnauthorized,
headers: serverInfo.noWsHeaders
});
Expand Down