mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-26 02:02:02 +00:00
feat(esp_http_server): Dynamically allocate http server's scratch buffer
In this commit, esp_http_server's http_parser scratch is made dynamic. User is asked to give limit size for header and URI, according to which scratch buufer allocates memory upto limits
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -35,9 +35,6 @@ extern "C" {
|
||||
* exceed the scratch buffer size and should at least be 8 bytes */
|
||||
#define PARSER_BLOCK_SIZE 128
|
||||
|
||||
/* Calculate the maximum size needed for the scratch buffer */
|
||||
#define HTTPD_SCRATCH_BUF MAX(HTTPD_MAX_REQ_HDR_LEN, HTTPD_MAX_URI_LEN)
|
||||
|
||||
/* Formats a log string to prepend context function name */
|
||||
#define LOG_FMT(x) "%s: " x, __func__
|
||||
|
||||
@@ -88,7 +85,11 @@ struct sock_db {
|
||||
*/
|
||||
struct httpd_req_aux {
|
||||
struct sock_db *sd; /*!< Pointer to socket database */
|
||||
char scratch[HTTPD_SCRATCH_BUF + 1]; /*!< Temporary buffer for our operations (1 byte extra for null termination) */
|
||||
char *scratch; /*!< Temporary buffer for our operations (1 byte extra for null termination) */
|
||||
uint16_t scratch_size_limit; /*!< Scratch buffer size limit */
|
||||
uint16_t scratch_cur_size; /*!< Scratch buffer cur size */
|
||||
uint16_t hdr_buf_size_limit; /*!< Header buffer size limit */
|
||||
uint16_t uri_buf_size_limit; /*!< URI buffer size limit */
|
||||
size_t remaining_len; /*!< Amount of data remaining to be fetched */
|
||||
char *status; /*!< HTTP response's status code */
|
||||
char *content_type; /*!< HTTP response's content type */
|
||||
|
Reference in New Issue
Block a user