mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-27 02:16:51 +00:00
fix(esp_http_server): WebSocket frame parsing errors
Fixes the Websocket frame pasring error, by making sure that two bytes are read compulsary for length bytes 126. Closes https://github.com/espressif/esp-idf/pull/15767 Closes https://github.com/espressif/esp-idf/issues/15235
This commit is contained in:

committed by
hrushikesh.bhosale

parent
adbec6eda2
commit
ab07377b11
@@ -132,6 +132,15 @@ struct httpd_data {
|
||||
httpd_err_handler_func_t *err_handler_fns;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Options for receiving HTTP request data
|
||||
*/
|
||||
typedef enum {
|
||||
HTTPD_RECV_OPT_NONE = 0,
|
||||
HTTPD_RECV_OPT_HALT_AFTER_PENDING = 1, /*!< Halt immediately after receiving from pending buffer */
|
||||
HTTPD_RECV_OPT_BLOCKING = 2, /*!< Receive blocking (don't return partial length) */
|
||||
} httpd_recv_opt_t;
|
||||
|
||||
/******************* Group : Session Management ********************/
|
||||
/** @name Session Management
|
||||
* Functions related to HTTP session management
|
||||
@@ -422,22 +431,27 @@ int httpd_send(httpd_req_t *req, const char *buf, size_t buf_len);
|
||||
*
|
||||
* @note The exposed API httpd_recv() is simply this function with last parameter
|
||||
* set as false. This function is used internally during reception and
|
||||
* processing of a new request. The option to halt after receiving pending
|
||||
* data prevents the server from requesting more data than is needed for
|
||||
* completing a packet in case when all the remaining part of the packet is
|
||||
* in the pending buffer.
|
||||
* processing of a new request.
|
||||
*
|
||||
* There are 2 options available that affect the behavior of the function:
|
||||
* - HTTPD_RECV_OPT_HALT_AFTER_PENDING
|
||||
* The option to halt after receiving pending data prevents the server from
|
||||
* requesting more data than is needed for completing a packet in case when
|
||||
* all the remaining part of the packet is in the pending buffer.
|
||||
*
|
||||
* - HTTPD_RECV_OPT_BLOCKING
|
||||
* The option to not return until the `buf_len` bytes have been read.
|
||||
*
|
||||
* @param[in] req Pointer to new HTTP request which only has the socket descriptor
|
||||
* @param[out] buf Pointer to the buffer which will be filled with the received data
|
||||
* @param[in] buf_len Length of the buffer
|
||||
* @param[in] halt_after_pending When set true, halts immediately after receiving from
|
||||
* pending buffer
|
||||
* @param[in] opt Receive option
|
||||
*
|
||||
* @return
|
||||
* - Length of data : if successful
|
||||
* - ESP_FAIL : if failed
|
||||
*/
|
||||
int httpd_recv_with_opt(httpd_req_t *r, char *buf, size_t buf_len, bool halt_after_pending);
|
||||
int httpd_recv_with_opt(httpd_req_t *r, char *buf, size_t buf_len, httpd_recv_opt_t opt);
|
||||
|
||||
/**
|
||||
* @brief For un-receiving HTTP request data
|
||||
|
Reference in New Issue
Block a user