feat(esp_http_server): Modified the calculation of buf_len

Modified the calculation of buf_len, so that scratch buffer allocates
the memory according to requirement and not extra (except the last read chunk)
This commit is contained in:
hrushikesh.bhosale
2025-01-28 15:47:30 +05:30
parent 97b6043435
commit 9846584def
19 changed files with 120 additions and 94 deletions

View File

@@ -31,8 +31,7 @@ extern "C" {
#endif
/* Size of request data block/chunk (not to be confused with chunked encoded data)
* that is received and parsed in one turn of the parsing process. This should not
* exceed the scratch buffer size and should at least be 8 bytes */
* that is received and parsed in one turn of the parsing process. */
#define PARSER_BLOCK_SIZE 128
/* Formats a log string to prepend context function name */
@@ -86,10 +85,10 @@ struct sock_db {
struct httpd_req_aux {
struct sock_db *sd; /*!< Pointer to socket database */
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 scratch_size_limit; /*!< Scratch buffer size limit (By default this value is set to CONFIG_HTTPD_MAX_REQ_HDR_LEN, overwrite is possible) */
size_t scratch_cur_size; /*!< Scratch buffer cur size (By default this value is set to CONFIG_HTTPD_MAX_URI_LEN, overwrite is possible) */
size_t max_req_hdr_len; /*!< Header buffer size limit */
size_t max_uri_len; /*!< 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 */