HTTP Client: What happens if the server response is too large?
Posted: Wed Apr 17, 2024 11:41 am
Hi there,
I am using the HTTP client to do HTTP requests. One request should return a JSON that might be multiple megabytes large. I want to handle the case that it is larger than the available RAM. How do I do that properly?
The HTTP client docs (https://docs.espressif.com/projects/esp ... lient.html) do not specify much about the data_len attribute of the esp_http_client_event struct. Since I couldn't find a KConfig setting for some static buffer size for the HTTP client, I assume the memory for the event payload is allocated on the heap. What happens if malloc fails? Will I get an HTTP_EVENT_ERROR?
Also, I cannot change the API endpoint to use chunked encoding.
Thanks in advance!
I am using the HTTP client to do HTTP requests. One request should return a JSON that might be multiple megabytes large. I want to handle the case that it is larger than the available RAM. How do I do that properly?
The HTTP client docs (https://docs.espressif.com/projects/esp ... lient.html) do not specify much about the data_len attribute of the esp_http_client_event struct. Since I couldn't find a KConfig setting for some static buffer size for the HTTP client, I assume the memory for the event payload is allocated on the heap. What happens if malloc fails? Will I get an HTTP_EVENT_ERROR?
Also, I cannot change the API endpoint to use chunked encoding.
Thanks in advance!