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

permessage-deflate decompression support in websocket #3263

Merged
merged 20 commits into from
May 20, 2024
2 changes: 1 addition & 1 deletion lib/web/websocket/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function establishWebSocketConnection (url, protocols, client, ws, onEstablish,
// 9. Let permessageDeflate be a user-agent defined
// "permessage-deflate" extension header value.
// https://github.com/mozilla/gecko-dev/blob/ce78234f5e653a5d3916813ff990f053510227bc/netwerk/protocol/websocket/WebSocketChannel.cpp#L2673
const permessageDeflate = options.node?.['client-extensions'] ?? ''
const permessageDeflate = 'permessage-deflate'
KhafraDev marked this conversation as resolved.
Show resolved Hide resolved

// 10. Append (`Sec-WebSocket-Extensions`, permessageDeflate) to
// request’s header list.
Expand Down
13 changes: 0 additions & 13 deletions lib/web/websocket/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,14 +549,6 @@ webidl.converters['DOMString or sequence<DOMString>'] = function (V, prefix, arg
return webidl.converters.DOMString(V, prefix, argument)
}

webidl.converters.WebSocketInitNodeOptions = webidl.dictionaryConverter([
{
key: 'client-extensions',
converter: webidl.converters.DOMString,
defaultValue: () => ''
}
])

// This implements the proposal made in https://github.com/whatwg/websockets/issues/42
webidl.converters.WebSocketInit = webidl.dictionaryConverter([
{
Expand All @@ -572,11 +564,6 @@ webidl.converters.WebSocketInit = webidl.dictionaryConverter([
{
key: 'headers',
converter: webidl.nullableConverter(webidl.converters.HeadersInit)
},
{
key: 'node',
converter: webidl.converters.WebSocketInitNodeOptions,
defaultValue: () => ({})
}
])

Expand Down
12 changes: 3 additions & 9 deletions test/autobahn/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,19 @@ let currentTest = 1
let testCount

const autobahnFuzzingserverUrl = process.env.FUZZING_SERVER_URL || 'ws://localhost:9001'
const options = {
node: {
'client-extensions': 'permessage-deflate'
}
}

function nextTest () {
let ws

if (currentTest > testCount) {
ws = new WebSocket(`${autobahnFuzzingserverUrl}/updateReports?agent=undici`, options)
ws = new WebSocket(`${autobahnFuzzingserverUrl}/updateReports?agent=undici`)
return
}

console.log(`Running test case ${currentTest}/${testCount}`)

ws = new WebSocket(
`${autobahnFuzzingserverUrl}/runCase?case=${currentTest}&agent=undici`,
options
`${autobahnFuzzingserverUrl}/runCase?case=${currentTest}&agent=undici`
)
ws.addEventListener('message', (data) => {
ws.send(data.data)
Expand All @@ -38,7 +32,7 @@ function nextTest () {
})
}

const ws = new WebSocket(`${autobahnFuzzingserverUrl}/getCaseCount`, options)
const ws = new WebSocket(`${autobahnFuzzingserverUrl}/getCaseCount`)
ws.addEventListener('message', (data) => {
testCount = parseInt(data.data)
})
Expand Down
Loading