Commit eeb77b2
Adds opt-in per-message DEFLATE compression for WebSocket connections,
negotiated during the handshake. Enable with `compress=true` on the client
`open(...)`, the server `listen!(...)`, or `upgrade(...)`; it is negotiated
per connection and transparently falls back to uncompressed frames if either
side declines.
Implementation (src/http_websocket_pmce.jl):
- Raw DEFLATE via thin Zlib_jll bindings (negative windowBits), driving
Z_SYNC_FLUSH with the 0x00 0x00 0xff 0xff trailer strip/append trick
(RFC 7692 §7.2). The CodecZlib transcode API cannot express sync-flush or
context takeover, so we go to zlib directly. Adds Zlib_jll as a dep.
- Per-connection context-takeover or no_context_takeover, negotiated window
bits, the empty-message 0x00 rule (§7.2.3.6), and a decompression-bomb
guard bounded by `maxframesize`.
- Full Sec-WebSocket-Extensions negotiation: client offer, server accept
(declining unknown params / unsupported 8-bit windows), client validation
of the server response.
Codec integration: RSV1 is accepted only when negotiated and only on the
first frame of a data message; the decoder defers UTF-8 validation for
compressed text (validated after the whole message is inflated). Outgoing
data messages are compressed as one frame; control frames are never
compressed.
Tests: 45 codec/negotiation/end-to-end cases (no docker needed). Autobahn
with compression enabled: 271 cases, zero failures, all 24 permessage-deflate
cases (12.*/13.*) OK and core cases 1-11 unaffected.
Existing WS suites unchanged: codec 122, client 20, server 35, integration 42.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 89341f0 commit eeb77b2
8 files changed
Lines changed: 637 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
61 | 89 | | |
62 | 90 | | |
63 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
204 | 211 | | |
205 | 212 | | |
206 | 213 | | |
| |||
223 | 230 | | |
224 | 231 | | |
225 | 232 | | |
| 233 | + | |
| 234 | + | |
226 | 235 | | |
227 | 236 | | |
228 | 237 | | |
| |||
266 | 275 | | |
267 | 276 | | |
268 | 277 | | |
269 | | - | |
270 | 278 | | |
271 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
272 | 285 | | |
273 | 286 | | |
274 | 287 | | |
| |||
278 | 291 | | |
279 | 292 | | |
280 | 293 | | |
| 294 | + | |
| 295 | + | |
281 | 296 | | |
282 | 297 | | |
283 | 298 | | |
| |||
366 | 381 | | |
367 | 382 | | |
368 | 383 | | |
369 | | - | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
370 | 388 | | |
371 | 389 | | |
372 | 390 | | |
373 | 391 | | |
374 | 392 | | |
375 | 393 | | |
376 | | - | |
| 394 | + | |
377 | 395 | | |
378 | | - | |
| 396 | + | |
379 | 397 | | |
380 | 398 | | |
381 | 399 | | |
| |||
470 | 488 | | |
471 | 489 | | |
472 | 490 | | |
| 491 | + | |
| 492 | + | |
473 | 493 | | |
474 | 494 | | |
475 | 495 | | |
476 | 496 | | |
477 | 497 | | |
| 498 | + | |
478 | 499 | | |
479 | 500 | | |
| 501 | + | |
480 | 502 | | |
481 | 503 | | |
482 | 504 | | |
| |||
488 | 510 | | |
489 | 511 | | |
490 | 512 | | |
| 513 | + | |
491 | 514 | | |
492 | 515 | | |
493 | 516 | | |
| |||
547 | 570 | | |
548 | 571 | | |
549 | 572 | | |
550 | | - | |
| 573 | + | |
551 | 574 | | |
552 | 575 | | |
553 | 576 | | |
| |||
565 | 588 | | |
566 | 589 | | |
567 | 590 | | |
| 591 | + | |
568 | 592 | | |
569 | 593 | | |
570 | 594 | | |
| |||
0 commit comments