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

Support permessage-deflate for websockets #31

Open
stopachka opened this issue Jan 8, 2024 · 1 comment
Open

Support permessage-deflate for websockets #31

stopachka opened this issue Jan 8, 2024 · 1 comment

Comments

@stopachka
Copy link

stopachka commented Jan 8, 2024

Hey team!

I've been using ring-undertow-adapter and it's been great! One feature we needed recently, is to enable permessage-deflate for websockets. To do this, we patched ring.adapter.undertow/ws-request like so:

(defn ws-request [^HttpServerExchange exchange ^IPersistentMap headers ^WebSocketConnectionCallback callback]
  (let [handler (->  (WebSocketProtocolHandshakeHandler. callback)
                     (.addExtension (PerMessageDeflateHandshake. true 6)))]
    (when headers
      (set-headers (.getResponseHeaders exchange) headers))
    (.handleRequest handler exchange)))

This resulted in quite a nice perf bump for slow connections.

Would you be interested in upstreaming some option for permessage-deflate? Happy to pop in a PR. Maybe we can include this as an option in the :undertow/websocket map.

@stopachka stopachka changed the title Support for permessage-deflate for websockets Support permessage-deflate for websockets Jan 8, 2024
@nikolap
Copy link
Member

nikolap commented Jan 9, 2024

Hey! This looks good, thanks for the improvement. I'd like the idea of it as a param. Would you be interested in pushing a PR for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants