unjs / crossws

🔌 Cross-platform WebSocket Servers for Node.js, Deno, Bun and Cloudflare Workers.
https://crossws.unjs.io
Other
277 stars 10 forks source link

Enable permessage-deflate to have websocket compression #18

Open Yasso9 opened 4 months ago

Yasso9 commented 4 months ago

Describe the feature

Hi, first thanks to this very cool library and the integration with nitro and nuxt.

Is it possible to have Sec-WebSocket-Extensions: permessage-deflate when answering a client connection ? Currently it does not respond to enabling permessage-deflate when the client ask to like on this one :

Screenshot from 2024-03-01 12-03-42

I have Sec-WebSocket-Extensions: permessage-deflate on the request header but nothing on the response header.

Additional information

Yasso9 commented 4 months ago

Is having this sufficient inside the defineWebSocketHandler object ?

upgrade(req) {
  return {
    headers: {
      "sec-websocket-extensions": "permessage-deflate",
    },
  };
},