esp-request
esp-request copied to clipboard
How to get body of the response?
Hi, first of all good job! How to get body or payload of http response besides status code? Trying to get something out of response inside the request but failed. Where is it? Thanks!
Update after few more testing. It seems response body saved in buffer->data, but not always.... For the same URL, bytes_read/bytes_write counter might have different value after long run. For quite high possibility in my testing (HTTP GET request, and JSON format payload in response body around 200Bytes), response content not completely saved into buffer. Is it caused by HTTP response in multiple TCP packets?
You have to register a callback function and process/buffer the response yourself:
int download_callback(request_t *req, char *data, int len) { /* use data */ }
req_setopt(req, REQ_FUNC_DOWNLOAD_CB, download_callback);
We are integrating new HTTP client to IDF, currently placed at https://github.com/espressif/esp-adf/tree/master/components/esp_http_client
This project will not be continued. Thank you for reporting the issues