Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WebSocketStream] Websocket handshake User-Agent header duplicated #26866

Open
vinhjaxt opened this issue Nov 14, 2024 · 0 comments
Open

[WebSocketStream] Websocket handshake User-Agent header duplicated #26866

vinhjaxt opened this issue Nov 14, 2024 · 0 comments
Assignees
Labels
ext/websocket related to the ext/websocket crate

Comments

@vinhjaxt
Copy link

Version: Deno/2.0.6

Step 1
Websocket Stream client (ws.ts):

const wss = new WebSocketStream('ws://1.1.1.1/' /* over http to see handshake request */, {
    headers: {
      'User-Agent': 'My-UA'
    }
})

const { readable, writable } = await wss.opened
console.log('Connected')

Step 2
Open Wireshark to capture websocket's http handshake request

Step 3
Run client:

deno --allow-net --unstable-net ws.ts

Result
http handshake request

GET / HTTP/1.1
host: 1.1.1.1
upgrade: websocket
connection: Upgrade
sec-websocket-key: ZZPd2TFAskpUnsM+/1fgDQ==
user-agent: Deno/2.0.6
user-agent: My-UA
sec-websocket-version: 13

image

=> Some web servers will concat duplicate header to one or array that leads to the wrong user-agent header

Reason
Deno set default User-Agent header value (array) into a fetch request
Deno append new headers of WebSocketStream into existing fetch's headers array

@bartlomieju bartlomieju added the ext/websocket related to the ext/websocket crate label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ext/websocket related to the ext/websocket crate
Projects
None yet
Development

No branches or pull requests

3 participants