Skip to content

socket.handshake.headers vs socket.request.headers #4607

Answered by darrachequesne
thernstig asked this question in Q&A
Discussion options

You must be logged in to vote

Hi!

socket.handshake.headers and socket.request.headers are the exact same object.

socket.io/lib/socket.ts

Lines 288 to 290 in 0c0eb00

private buildHandshake(auth: object): Handshake {
return {
headers: this.request.headers,

Is socket.request.headers only ever set once?

Yes, those are the headers of the first HTTP request.

And socket.handshake.headers also only set once in case the transport uses Websocket, but set each time on the HTTP request if using HTTP long polling?

No, they are set once in all cases.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@thernstig
Comment options

@darrachequesne
Comment options

Answer selected by thernstig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants