Obtaining the https response using esp_http_client_perform

Posts: 2
Joined: Thu Jan 07, 2021 2:48 am

Obtaining the https response using esp_http_client_perform

Postby antusystem » Sat Jan 09, 2021 8:13 pm

Hi, I'm using the ESP-IDF v.4.2. I'm using the esp_http_client example to make an HTTPS request. Guiding me from the https_with_url function I could establish a connecting with the web, but I want to know the actual content from the response. I cannot see how to do this with the function esp_http_client_perform.

Afterwards, I tried using the base of the http_native_request function, making the changes so I could connect through HTTPS. I manage to do it and also could read the content response from the server to the HTTPS request using esp_http_client_read_response.

So, because esp_http_client_perform is easier to use than all the way with the native path, I'm trying to extract this information but I could not do it. I also try adding a queue in the handler to send this data, but it didn't work, the data arrive incomplete or not even readable.

Hopefully, some of you might know this. Thanks

Note: here you can see the esp_http_client example: https://github.com/espressif/esp-idf/bl ... _example.c

Edit: reading better the esp_http_client and found that they declare a variable for the buffer and if in the config for the handler of the http you pass this variable to .user_data you, after using esp_http_client_perform you can check the response from the server there.

Code: Select all

    char buffer[MAX_HTTP_OUTPUT_BUFFER] = {0}; 
    esp_http_client_config_t config = {
        .url = "https://postman.org",
        .transport_type = HTTP_TRANSPORT_OVER_SSL,
        .event_handler = _http_event_handler,
        .user_data = buffer,        // Pass address of local buffer to get response
The thing I want to know now is how to print the https request send to the server, for both GET and POST cases.

Who is online

Users browsing this forum: misiek1994 and 57 guests