I can't seem to find a way to do so.
Here's what I think a generic request would look like:
Code: Select all
esp_http_client_handle_t client;.
void setup_client(void){
//Somewhere Once
esp_http_client_config_t config = {
.url = "...",
.is_async = true,
.event_handler = ...,
.crt_bundle_attach = esp_crt_bundle_attach,
};
client = esp_http_client_init(&config);
}
void do_example_request(void){
//Wait for client to complete outstanding request
while(!esp_http_client_idle(client) && ESP_ERR_HTTP_EAGAIN == esp_http_client_perform(client)){
//esp_http_client_perform() will run the event handler
}
//These might be different from any previous request,
//so we cannot set them until we know the client is idle(either disconnected, or between requests)
esp_http_client_set_header(client, "...", "...");
esp_http_client_set_method(client, HTTP_METHOD_GET);
esp_http_client_open(client, 0);
}
void idle_poll(void){
//Wait for client to complete outstanding request
if(!esp_http_client_idle(client)){
//esp_http_client_perform() will run the event handler
esp_http_client_perform(client);
}
}