Skip to content

Support permessage-deflate for websockets #31

Open
@stopachka

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions