mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-28 21:29:50 +01:00
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:
@@ -294,6 +294,8 @@ esp_err_t httpd_resp_send(httpd_req_t *r, const char *buf, ssize_t buf_len)
|
||||
if (httpd_send_all(r, cr_lf_seperator, strlen(cr_lf_seperator)) != ESP_OK) {
|
||||
return ESP_ERR_HTTPD_RESP_SEND;
|
||||
}
|
||||
struct httpd_data *hd = (struct httpd_data *) r->handle;
|
||||
hd->http_server_state = HTTP_SERVER_EVENT_HEADERS_SENT;
|
||||
esp_http_server_dispatch_event(HTTP_SERVER_EVENT_HEADERS_SENT, &(ra->sd->fd), sizeof(int));
|
||||
|
||||
/* Sending content */
|
||||
@@ -306,6 +308,7 @@ esp_err_t httpd_resp_send(httpd_req_t *r, const char *buf, ssize_t buf_len)
|
||||
.fd = ra->sd->fd,
|
||||
.data_len = buf_len,
|
||||
};
|
||||
hd->http_server_state = HTTP_SERVER_EVENT_SENT_DATA;
|
||||
esp_http_server_dispatch_event(HTTP_SERVER_EVENT_SENT_DATA, &evt_data, sizeof(esp_http_server_event_data));
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -325,6 +328,7 @@ esp_err_t httpd_resp_send_chunk(httpd_req_t *r, const char *buf, ssize_t buf_len
|
||||
}
|
||||
|
||||
struct httpd_req_aux *ra = r->aux;
|
||||
struct httpd_data *hd = (struct httpd_data *) r->handle;
|
||||
const char *httpd_chunked_hdr_str = "HTTP/1.1 %s\r\nContent-Type: %s\r\nTransfer-Encoding: chunked\r\n";
|
||||
const char *colon_separator = ": ";
|
||||
const char *cr_lf_seperator = "\r\n";
|
||||
@@ -404,6 +408,7 @@ esp_err_t httpd_resp_send_chunk(httpd_req_t *r, const char *buf, ssize_t buf_len
|
||||
.fd = ra->sd->fd,
|
||||
.data_len = buf_len,
|
||||
};
|
||||
hd->http_server_state = HTTP_SERVER_EVENT_SENT_DATA;
|
||||
esp_http_server_dispatch_event(HTTP_SERVER_EVENT_SENT_DATA, &evt_data, sizeof(esp_http_server_event_data));
|
||||
|
||||
return ESP_OK;
|
||||
@@ -613,6 +618,8 @@ int httpd_req_recv(httpd_req_t *r, char *buf, size_t buf_len)
|
||||
}
|
||||
ra->remaining_len -= ret;
|
||||
ESP_LOGD(TAG, LOG_FMT("received length = %d"), ret);
|
||||
struct httpd_data *hd = (struct httpd_data *) r->handle;
|
||||
hd->http_server_state = HTTP_SERVER_EVENT_ON_DATA;
|
||||
esp_http_server_event_data evt_data = {
|
||||
.fd = ra->sd->fd,
|
||||
.data_len = ret,
|
||||
|
||||
Reference in New Issue
Block a user