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.
http client read response headers
Re: http client read response headers
How did you solve it? I came across the same issue. I need a cookie that is returned from a server, but the standard functions don't hand it over.
Re: http client read response headers
Turns out headers were all parsed via the event loop instead of the main functions. So when received, I just stored them in an array and processed them in the main function. I am unsure about cookies though.
Re: http client read response headers
Hi rfleming,
Can you expand a bit more on how to read the response headers?
I’m trying to do the same to read the Mesh lamp nodes from mesh_info call and still could not get it to work.
I see the four headers coming in ON_HEADER event, but evt length and data do not seem to be populated.
Can you expand a bit more on how to read the response headers?
I’m trying to do the same to read the Mesh lamp nodes from mesh_info call and still could not get it to work.
I see the four headers coming in ON_HEADER event, but evt length and data do not seem to be populated.
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design
Re: http client read response headers
I solved the issue with the callback functions of the HTTP parser. They read everything and can make it explicit. I described this here:
viewtopic.php?f=13&t=21598
I am, however, not sure if this is possible only with IDF 4.2 and later.
viewtopic.php?f=13&t=21598
I am, however, not sure if this is possible only with IDF 4.2 and later.
Re: http client read response headers
Thanks Stephan,
it's actually in the http_client example and I just missed it.
Here an example to query a root mesh lamp and ask for the child nodes.
it's actually in the http_client example and I just missed it.
Here an example to query a root mesh lamp and ask for the child nodes.
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design
Who is online
Users browsing this forum: MicroController and 155 guests