esp-idf-svc
esp-idf-svc copied to clipboard
EspHttpClient doesn't support `keep-alive`
Description
The current implementation of EspHttpClient doesn't support the keep-alive functionnality of HTTP connections.
According to the documentation, we can specify the following attributes to esp_http_client_config_t:
Also, the current implementation doesn't call esp_http_client_close after the keep-alive timeout or max as been reached.
Expected behavior
We should be able to pass the keep-alive attributes to EspHttpClientConfiguration either by specifiying each attributes, or by passing a struct, that contains the properties, whichever is the most idiomatic.
esp_http_client_close should also be called, after the connection has been idle for the number of seconds specified in timeout, or after reaching the maximum number of requests that can be sent on this connection.
External documentation
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive
@AnthonyGrondin Would you be willing to contribute a PR against master for this?
I don't think I have the required knowledge to come up with an ideal implementation of it.
The main challenge here, is to work asynchronously, since the implementation has to work kind of like a watchdog. Upon a new request, a timer is started, with the value of the keep-alive header, and decrements each second. If another request is made during that period, before the timer reaches 0, it has to be reset from the value of the keep-alive header in that request.
I don't think I have the required knowledge to come up with an ideal implementation of it.
The main challenge here, is to work asynchronously, since the implementation has to work kind of like a watchdog. Upon a new request, a timer is started, with the value of the
keep-aliveheader, and decrements each second. If another request is made during that period, before the timer reaches 0, it has to be reset from the value of thekeep-aliveheader in that request.
Are you sure that Espressif does not have an automatic keep-alive management?