http_server: WebSocket server to set flag in transmitted messages by default

Add logic to set `FIN` flag automatically for transmitted WS frames, but
if `fragmented` option set indicating an expert/manual mode, then the
`FIN` flag is set according to the `final` option.
This commit is contained in:
David Cermak
2020-06-19 10:54:47 +02:00
committed by bot
parent 52150c2cd2
commit 005f21accc
4 changed files with 19 additions and 5 deletions
@@ -10,7 +10,12 @@ ws_server_example_test.py could be used as a simple WS client).
The server registers WebSocket handler which echoes back the received WebSocket frame. It also demonstrates
use of asynchronous send, which is triggered on reception of a certain message.
Please note that the WebSocket HTTPD server does not automatically fragment messages, so the application code must deal with fragmentation, setting `final` flag as appropriate. Single (complete/unfragmented) WebSocket frames must have the `FIN` flag set to be accepted as valid (see [RFC6455, section 5.4](https://tools.ietf.org/html/rfc6455#section-5.4)).
Please note that the WebSocket HTTP server does not automatically fragment messages.
Each outgoing frame has the FIN flag set by default.
In case an application wants to send fragmented data, it must be done manually by setting the
`fragmented` option and using the `final` flag as described in [RFC6455, section 5.4](https://tools.ietf.org/html/rfc6455#section-5.4).
### Hardware Required