Skip to content

Commit 92b32e8

Browse files
committed
Fire WS upstream event with 'ws' protocol, not 'http'
This matches the behaviour for exposed websocket event data elsewhere, which uses ws/wss as the protocol consistently throughout.
1 parent 29a9ea5 commit 92b32e8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/rules/websockets/websocket-handlers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,9 @@ export class PassThroughWebSocketHandler extends PassThroughWebSocketHandlerDefi
396396
const upstreamReq = (upstreamWebSocket as any as { _req: http.ClientRequest })._req;
397397
options.emitEventCallback('passthrough-websocket-connect', {
398398
method: upstreamReq.method,
399-
protocol: upstreamReq.protocol.replace(/:$/, ''),
399+
protocol: upstreamReq.protocol
400+
.replace(/:$/, '')
401+
.replace(/^http/, 'ws'),
400402
hostname: upstreamReq.host,
401403
port: effectivePort.toString(),
402404
path: upstreamReq.path,

test/integration/subscriptions/rule-events.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ describe("Rule event subscriptions", () => {
342342
const connectEvent = ruleEvents[0].eventData;
343343
expect(_.omit(connectEvent, 'rawHeaders')).to.deep.equal({
344344
method: 'GET',
345-
protocol: 'http',
345+
protocol: 'ws',
346346
hostname: 'localhost',
347347
// This reports the *modified* port, not the original:
348348
port: remoteServer.port.toString(),

0 commit comments

Comments
 (0)