feat(http_server): Added API to get scratch buffer data

1. Added the API in esp_http_server to get the raw headers data
from the scratch buffer.
2. This data will be unparsed.

Closes https://github.com/espressif/esp-idf/issues/15857
This commit is contained in:
hrushikesh.bhosale
2025-06-05 12:08:12 +05:30
parent d73e172d31
commit 9f6ab55a5b
6 changed files with 103 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -126,6 +126,7 @@ static esp_err_t httpd_accept_conn(struct httpd_data *hd, int listen_fd)
goto exit;
}
ESP_LOGD(TAG, LOG_FMT("complete"));
hd->http_server_state = HTTP_SERVER_EVENT_ON_CONNECTED;
esp_http_server_dispatch_event(HTTP_SERVER_EVENT_ON_CONNECTED, &new_fd, sizeof(int));
return ESP_OK;
exit:
@@ -539,6 +540,7 @@ esp_err_t httpd_start(httpd_handle_t *handle, const httpd_config_t *config)
}
*handle = (httpd_handle_t)hd;
hd->http_server_state = HTTP_SERVER_EVENT_START;
esp_http_server_dispatch_event(HTTP_SERVER_EVENT_START, NULL, 0);
return ESP_OK;
@@ -593,3 +595,12 @@ esp_err_t httpd_stop(httpd_handle_t handle)
esp_http_server_dispatch_event(HTTP_SERVER_EVENT_STOP, NULL, 0);
return ESP_OK;
}
esp_http_server_event_id_t httpd_get_server_state(httpd_handle_t handle)
{
struct httpd_data *hd = (struct httpd_data *) handle;
if (hd == NULL) {
return HTTP_SERVER_EVENT_ERROR;
}
return hd->http_server_state;
}