Add support for partial websocket frame payload reads (IDFGH-14913) #15622
+49
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Added support for partial websocket frame payload reads. This was implemented as a separate function
httpd_ws_recv_frame_part
to keep the backwards compatibility with subtlehttpd_ws_recv_frame
behavior, that being that it returns an undocumented error whenmax_len < pkt->len
.httpd_ws_frame_t
now also contains newleft_len
field, which is used to keep track of the yet to be received data and calculating the mask offset. In the future, it shall also be used for implementing partial frame sends.Related
Testing
This feature was tested by me on my project and on some additional edge cases, including trying to over-receive (reading more data than there is in a frame payload) and to under-receive (leaving data unprocessed and unread and completing the request). No unexpected errors were identified.
The change itself is not very complex, however in my opinion it is imperative that someone with more knowledge about the ESP HTTP stack verifies that there is no deeper issues with this implementation (and the idea itself, for that matter), which I may have missed.
Checklist
Before submitting a Pull Request, please ensure the following: