http client read response headers
Posted: Thu Feb 11, 2021 1:40 am
Hi all,
I currently have my esp32-Wrover-E setup as a http client. The client connects to my server and sends and receives JSON formatted data. In this situation I use the headers to determine the content type and since I will be receving roughly 2k data, I required to use the esp_http_client_open/esp_http_client_write method instead of esp_http_client_perform.
Since using this method, the function esp_http_client_fetch_headers is actually used for getting data length from the header and not the headers itself.
Looking through the API there doesn't appear to be any method for getting these headers in response from the server. I am doing this synchronously (so is_async=false). Even so I implemented the callback function to check if it comes through there, but it too doesn't show any headers with its HTTP_EVENT_ON_HEADER event_id.
Finally I went looking through the esp_http_client.c file and looked through the structure for the esp_http_client_handle_t and noted that it 'could' be accessed via client->response->headers. Though this always appears to be null and never populated - hence no api for it.
So my question is, does this functionality current exist in esp-idf v4.1? Else I may try to write my own function extending the esp_http_client_fetch_headers to include the headers I required.
I currently have my esp32-Wrover-E setup as a http client. The client connects to my server and sends and receives JSON formatted data. In this situation I use the headers to determine the content type and since I will be receving roughly 2k data, I required to use the esp_http_client_open/esp_http_client_write method instead of esp_http_client_perform.
Since using this method, the function esp_http_client_fetch_headers is actually used for getting data length from the header and not the headers itself.
Looking through the API there doesn't appear to be any method for getting these headers in response from the server. I am doing this synchronously (so is_async=false). Even so I implemented the callback function to check if it comes through there, but it too doesn't show any headers with its HTTP_EVENT_ON_HEADER event_id.
Finally I went looking through the esp_http_client.c file and looked through the structure for the esp_http_client_handle_t and noted that it 'could' be accessed via client->response->headers. Though this always appears to be null and never populated - hence no api for it.
So my question is, does this functionality current exist in esp-idf v4.1? Else I may try to write my own function extending the esp_http_client_fetch_headers to include the headers I required.