Skip to content

Add handshake response info to undici:websocket:open diagnostic event #4394

@islandryu

Description

@islandryu

This would solve...

Network.webSocketHandshakeResponseReceived in the Chrome DevTools Protocol (CDP), we need access to the handshake's HTTP response details (status, statusText, headers) at the time the connection is established.
https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-webSocketHandshakeResponseReceived

The implementation should look like...

Add this field to undici:websocket:open

{
  handshakeResponse: {
    status: 101,
    statusText: 'Switching Protocols',
    headers: { Upgrade: 'websocket', Connection: 'Upgrade', ... }
  }
}

I have also considered...

Create a dedicated handshake-specific event, similar to CDP.

Additional context

I am adding WebSocket inspector support in the following PR.
nodejs/node#59404

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomerswebsocketPull requests or issues related to websocket and its standard

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions