Skip to content

permessage-deflate support#868

Closed
Mixfair wants to merge 3 commits into
JuliaWeb:masterfrom
Mixfair:ws-permessage-deflate
Closed

permessage-deflate support#868
Mixfair wants to merge 3 commits into
JuliaWeb:masterfrom
Mixfair:ws-permessage-deflate

Conversation

@Mixfair

@Mixfair Mixfair commented Jun 27, 2022

Copy link
Copy Markdown

Hi.
Sharing my example of implementing permessage-deflate using CodecZlib in continuation #853.
In the process, I encountered fragmentation difficulties, since the opcode is calculated during the process of sending data and we do not know about the type of compressed data. Therefore, I decided to separately compress a string into a string, an array into an array before sending. Also moved utf-8 check after unpacking. Tested with Chrome and Julia client.

Please, review it

Server:

WebSockets.listen(host, port; binary=false, isdeflate=true) do ws
    @async while true
        sleep(2)
        payload = WebSockets.compress("Hello")                       # if fragmentation true
        WebSockets.send(ws, [payload[1:2], payload[3:end]])
        # payload = "Hello"                                          # if fragmentation false
        # WebSockets.send(ws, payload)
    end
    for msg in ws
        @info "Received: ", msg
    end
end

Client:

WebSockets.open("ws://127.0.0.1:8080") do ws
    for msg in ws
        @info "Client received: ", msg
        # msg = WebSockets.compress(msg)                            # if fragmentation true
        WebSockets.send(ws, msg)
    end
end

@Mixfair Mixfair force-pushed the ws-permessage-deflate branch from 503e4f8 to 2c9a6cb Compare June 27, 2022 12:55
Comment thread src/WebSockets.jl Outdated
Comment thread src/WebSockets.jl Outdated
Comment thread src/WebSockets.jl Outdated
@Mixfair Mixfair force-pushed the ws-permessage-deflate branch from 3267f59 to fb7111e Compare August 5, 2022 12:50
@codecov-commenter

codecov-commenter commented Aug 5, 2022

Copy link
Copy Markdown

Codecov Report

Merging #868 (fb7111e) into master (cf706bc) will decrease coverage by 3.88%.
The diff coverage is 60.81%.

❗ Current head fb7111e differs from pull request most recent head c3a3b7c. Consider uploading reports for the commit c3a3b7c to get more accurate results

@@            Coverage Diff             @@
##           master     #868      +/-   ##
==========================================
- Coverage   80.12%   76.23%   -3.89%     
==========================================
  Files          36       36              
  Lines        2878     2925      +47     
==========================================
- Hits         2306     2230      -76     
- Misses        572      695     +123     
Impacted Files Coverage Δ
src/WebSockets.jl 51.82% <31.70%> (-36.00%) ⬇️
src/clientlayers/ConnectionRequest.jl 78.94% <90.00%> (+2.32%) ⬆️
src/ConnectionPool.jl 88.44% <100.00%> (-0.51%) ⬇️
src/HTTP.jl 74.32% <100.00%> (-8.73%) ⬇️
src/Handlers.jl 84.14% <100.00%> (+0.29%) ⬆️
src/clientlayers/RetryRequest.jl 74.41% <0.00%> (-2.33%) ⬇️
src/Messages.jl 87.03% <0.00%> (-0.62%) ⬇️
src/cookiejar.jl 77.01% <0.00%> (-0.58%) ⬇️
... and 1 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@Mixfair Mixfair force-pushed the ws-permessage-deflate branch from fb7111e to c3a3b7c Compare August 6, 2022 14:54
@quinnj

quinnj commented Jun 15, 2026

Copy link
Copy Markdown
Member

Implemented in #1308; sorry for the slow response/review here. As the websocket code has been completely re-done for the 2.0 release, I ended up doing the support along with the rewrite.

@quinnj quinnj closed this Jun 15, 2026
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

Successfully merging this pull request may close these issues.

4 participants