Allow applications to independently own outgoing PMD compression and incoming PMD decompression while retaining Beast’s WebSocket negotiation, framing, and I/O.
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- networking
Direzione di ricerca
Start with websocket::permessage_deflate, websocket::stream, and permessage_deflate_status, then review the existing read, write, async, and partial-write operations alongside RFC 7692. Done means applications can own outgoing compression and incoming decompression while Beast retains negotiation, framing, I/O, control-frame handling, and validation, with the specified status and message-state queries.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
In my application I want to close ws connection on uncontrolled queue growth (due to networking issues). What happens now when permesagedeflate(PMD) is enabled the queue grows due to bottleneck introduced by deflation. Right now there is no clean way to distinguish network from compressor contention. I want to be able to account for compression cost on message generation side so that I can throttle the source instead of dropping the connection. This proposal also solves #3014 and #1756.
I propose we add two independent fields to websocket::permessage_deflate:
bool external_compression = false; // Outgoing messages
bool external_decompression = false; // Incoming messages
With external compression enabled, reuse existing write, async_write, and partial-write operations:
compress(true)declares that the supplied bytes are already a valid PMD-encoded payload. Beast skips compression and sets RSV1 on the first frame.compress(false)declares an ordinary, uncompressed payload.- The setting is captured at message start and applies to all its fragments.
compLevel,memLevel, andmsg_size_thresholddo not affect outgoing payloads in this mode.- A compressed write without negotiated PMD fails before transmission.
Then conceptually:
ws.compress(message.is_compressed);
ws.async_write(net::buffer(message.payload), handler);
Beast continues handling fragmentation, masking, and text/binary opcodes. The opcode describes the original, decoded message.
With external decompression enabled, reuse existing read operations and add:
bool websocket::stream::got_compressed() const;
This query reports the received message’s RSV1 state after a successful read operation. Its value remains fixed throughout the message. In normal mode, Beast still returns decoded data; in external mode, compressed payloads remain encoded.
| Operation | Behavior in external decompression mode |
|---|---|
read / async_read |
Append unmasked payload bytes until the current WebSocket message is complete, joining its fragments. |
read_some / async_read_some |
Deliver chunks of unmasked payload bytes without waiting for the complete message. |
Neither operation inflates data nor inserts synthetic PMD trailer bytes. Read chunks need not align with DEFLATE blocks.
is_message_done() identifies completion of the WebSocket message, based on consuming its final fragment. A partial read may complete the message with zero additional payload bytes when the final fragment is empty. got_text() and got_binary() retain their existing meaning.
Beast continues processing control frames and validating WebSocket framing, including rejecting RSV1 when PMD was not negotiated.
Extend permessage_deflate_status with:
bool client_no_context_takeover = false;
bool server_no_context_takeover = false;
These report negotiated results when PMD is active:
client_no_context_takeovergoverns client-to-server traffic.server_no_context_takeovergoverns server-to-client traffic.
Together with the existing negotiated window sizes, they provide the settings needed by external codecs.
For each external direction, the application owns RFC 7692 payload processing, including message finalization and compression history. Incoming PMD finalization occurs once at WebSocket message completion, not after every read chunk. The external decoder must handle valid DEFLATE block arrangements and reject malformed or truncated payloads.
For externally decoded compressed messages, the application also validates decoded UTF-8 and enforces decoded-size limits during inflation. In external decompression mode, read_message_max bounds the received encoded payload across the whole message; it cannot bound its decoded size.
Transfer counts measure bytes supplied to or returned by Beast—encoded payload bytes where applicable, excluding WebSocket framing. Existing buffer-lifetime, serialization, and cancellation rules remain applicable.
PMD handshake validation, including window and context-takeover negotiation, remains Beast’s responsibility. These options change codec ownership without changing negotiation rules.
I can prepare POC PR for this if you believe it to be the right direction.
- Lingua principale
- C++
- Stelle
- 4.8k
- Fork
- 697
- Merge medio
- 20h 38m
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di boostorg/beast
-
http::message::keep_alive disagrees with the parser for repeated Connection fieldsForse già presa @ashtum l’ha presa 24 giorni fa. ApertaBug
boostorg/beast#3124 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
permessage-deflate: decide whether to reset the inflater when the peer agreed to no context takeoverForse di nuovo libera @ashtum l’ha presa 48 giorni fa e non c’è nessuna pull request aperta. Aperta
boostorg/beast#3118 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
boostorg/beast#3092 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
boostorg/beast#3064 · 6 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di boostorg/beast
Issue simili
-
agent:WSL code-review linux pri:medium refactoring
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
kind/enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 82/100
psi29a/d2decomped#691 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
CachyOS/packageinstaller#144 ·
I maintainer di solito rispondono entro 1 giorno
-
(S1 - Need confirmation)
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
CleverRaven/Cataclysm-DDA#89715 ·
I maintainer di solito rispondono entro 1 giorno