PONG frames (opcode 0xA) were never dispatched to the user's WebSocket
handler despite an existing comment stating they should be. The dispatch
condition `ra->ws_type < HTTPD_WS_TYPE_CLOSE` excluded PONG (0xA)
since CLOSE is 0x8.
This caused a critical secondary bug: when the server sends PING frames
and the client responds with PONG, httpd_ws_recv_frame() is never
called for the PONG, leaving the remaining frame bytes (second_byte
plus 4-byte mask_key) unconsumed in the TCP buffer. On the next
WebSocket read, these orphaned bytes are misinterpreted as a new frame
header, causing either "WS frame is not properly masked" errors or
EAGAIN timeouts with garbage length values, effectively destroying
the connection.
Add `ra->ws_type == HTTPD_WS_TYPE_PONG` to the dispatch condition so
PONG frames reach the user handler, which calls httpd_ws_recv_frame()
to properly consume the frame bytes from the socket.
Closes https://github.com/espressif/esp-idf/issues/18227
This commit added demo to receive websocket single frame in chunks
using newly added API httpd_ws_recv_frame_part() with optimized memory.
closes https://github.com/espressif/esp-idf/pull/15622
Make it possible to disable http(s) server events. This improves
performance of the server, as http server creates events on every signle
read or write to the socket.
1. In async requests, if the two or more requests are made on same
socket then it used to block the second request.
2. The main thread is used to block on select call. And there done
no FD_SET for particular fd.
Closes https://github.com/espressif/esp-idf/issues/16998
1. If the user wants authenticate the request, then user needs to do
this before upgrading the protocol to websocket.
2. To achieve this, added pre_handshake_callack, which will execute
before handshake, i.e. before switching protocol.
In httpd_register_uri_handler api, for the strdup function failure case was not
checked and not returned any error by freeing previously allocated memory, if the memory
allocation for strdup function did not gets successful.
Closes https://github.com/espressif/esp-idf/issues/15878
1. In httpd_req_async_handler_begin, the httpd_req_aux is locally malloced
and data is done memcpy to local httpd_req_aux from request'ss httpd_req_aux for
async request use-case, this causes scartch pointer from these two structs
pointing to same memory address.
2. In current workflow, the request's sratch buffer is freed in httpd_parse.c
httpd_req_cleanup api. Therefore if the user try to fetch the data (like headers)
from the scratch buffer, data will be not available.
3. Each request should have the deep copy of the scratch buffer. To retrive
the data later.
Closes https://github.com/espressif/esp-idf/issues/15587
res_buf was not freed for the chunk response type in case of
first_chunk_sent true condition.
This commit ensures that resp_buf is freed and few cosmetic
changes are made