I have one http client application which communicates to the Cloud. I use http client API's as follows:
1> esp_http_client_init.
2> esp_http_client_set_header to set the headers.
3> then 'esp_http_client_open' to open the connection.
4> esp_http_client_get_content_length
5> esp_http_client_write
6> esp_http_client_fetch_headers
7> esp_http_client_get_status_code
8> esp_http_client_is_chunked_response
9> esp_http_client_get_content_length
10> esp_http_client_get_status_code
11> esp_http_client_read
12> esp_http_client_cleanup
Currently I am opening a connection and closing it for every request.
But while trying to open the connection only at one time for few requests, I faced One issue that I am not able to add header using 'esp_http_client_set_header' after 'esp_http_client_open'.
using 'esp_http_client_set_header' after 'esp_http_client_open' doesn't writes header to the socket means it don't send those headers which are set after the 'esp_http_client_open' and my request goes without those headers and I receive negative response from cloud.
The esp_http_client writes only those headers to socket which are set before esp_http_client_open.
So Is there a way to set headers after opening the connection(esp_http_client_open) as I don't wan't to close my socket on each request?
issue in using esp_http_client
-
- Posts: 10
- Joined: Fri Oct 05, 2018 10:31 am
Re: issue in using esp_http_client
Hi there,
Please Guide Me. Thanks In advance.
Please Guide Me. Thanks In advance.
-
- Posts: 10
- Joined: Fri Oct 05, 2018 10:31 am
Re: issue in using esp_http_client
Currently I am using esp-idf-v3.1-beta1.
-
- Posts: 10
- Joined: Fri Oct 05, 2018 10:31 am
Re: issue in using esp_http_client
I think the fix for this issue is in branch release/v3.2(https://github.com/espressif/esp-idf/bl ... p_client.c) esp_http_client module but not yet released, am I wright?
Should I use this branch to resolve my issue?
Should I use this branch to resolve my issue?
Re: issue in using esp_http_client
Hi, vivek.vaghela
Sorry for the reply, our engineer has been looking into this and will reply soon.
Thanks.
Alvin
Best Regards
Sorry for the reply, our engineer has been looking into this and will reply soon.
Thanks.
Alvin
Best Regards
-
- Posts: 14
- Joined: Sat Dec 05, 2015 7:59 am
Re: issue in using esp_http_client
Hi @vivek.vaghela The esp_http_client_open will open the connection and write all http datas (include http header). If you want to set the HTTP header, you need to use esp_http_client_set_header before calling the esp_http_client_openvivek.vaghela wrote: ↑Mon Nov 26, 2018 5:49 amI have one http client application which communicates to the Cloud. I use http client API's as follows:
1> esp_http_client_init.
2> esp_http_client_set_header to set the headers.
3> then 'esp_http_client_open' to open the connection.
4> esp_http_client_get_content_length
5> esp_http_client_write
6> esp_http_client_fetch_headers
7> esp_http_client_get_status_code
8> esp_http_client_is_chunked_response
9> esp_http_client_get_content_length
10> esp_http_client_get_status_code
11> esp_http_client_read
12> esp_http_client_cleanup
Currently I am opening a connection and closing it for every request.
But while trying to open the connection only at one time for few requests, I faced One issue that I am not able to add header using 'esp_http_client_set_header' after 'esp_http_client_open'.
using 'esp_http_client_set_header' after 'esp_http_client_open' doesn't writes header to the socket means it don't send those headers which are set after the 'esp_http_client_open' and my request goes without those headers and I receive negative response from cloud.
The esp_http_client writes only those headers to socket which are set before esp_http_client_open.
So Is there a way to set headers after opening the connection(esp_http_client_open) as I don't wan't to close my socket on each request?
There is a way to write the HTTP header after esp_http_client_open by using esp_http_client_set_header in HTTP_EVENT_ON_CONNECTED event
-
- Posts: 10
- Joined: Fri Oct 05, 2018 10:31 am
Re: issue in using esp_http_client
Hi ESP_tuanpm ,
Thanks for the answer, But in my case:
I don't want to close the connection every time, after opening the connection first time for the first request I can call the esp_http_client_set_header api in the 'HTTP_EVENT_ON_CONNECTED', but what to do for the next requests without closing the connection, as the HTTP_EVENT_ON_CONNECTED will occur for the first time only.
Thanks for the answer, But in my case:
I don't want to close the connection every time, after opening the connection first time for the first request I can call the esp_http_client_set_header api in the 'HTTP_EVENT_ON_CONNECTED', but what to do for the next requests without closing the connection, as the HTTP_EVENT_ON_CONNECTED will occur for the first time only.
-
- Posts: 10
- Joined: Fri Oct 05, 2018 10:31 am
Re: issue in using esp_http_client
As there are new APIs esp_http_client_connect and esp_http_client_request_send in branch release/v3.2 which are separating the esp_http_client_open's process.vivek.vaghela wrote: ↑Wed Nov 28, 2018 5:55 amI think the fix for this issue is in branch release/v3.2(https://github.com/espressif/esp-idf/bl ... p_client.c) esp_http_client module but not yet released, am I wright?
Should I use this branch to resolve my issue?
Is this wright, can the above mention branch will solve my problem?
Who is online
Users browsing this forum: cdollar and 92 guests