EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #570 background imageLoading...
Page #570 background image
Chapter 2. API Reference
(continued from previous page)
.url = "http://httpbin.org/get",
};
esp_http_client_handle_t client = esp_http_client_init(&config);
// first request
err = esp_http_client_perform(client);
// second request
esp_http_client_set_url(client, "http://httpbin.org/anything")
esp_http_client_set_method(client, HTTP_METHOD_DELETE);
esp_http_client_set_header(client, "HeaderKey", "HeaderValue");
err = esp_http_client_perform(client);
esp_http_client_cleanup(client);
HTTPS
The HTTP client supports SSL connections using mbedtls, with the url configuration starting with https scheme
(or transport_type = HTTP_TRANSPORT_OVER_SSL). HTTPS support can be configured via CON-
FIG_ESP_HTTP_CLIENT_ENABLE_HTTPS (enabled by default).
Note: By providing information using HTTPS, the library will use the SSL transport type to connect to the server.
If you want to verify server, then need to provide additional certificate in PEM format, and provide to cert_pem
in esp_http_client_config_t
HTTPS example
static void https()
{
esp_http_client_config_t config = {
.url = "https://www.howsmyssl.com",
.cert_pem = howsmyssl_com_root_cert_pem_start,
};
esp_http_client_handle_t client = esp_http_client_init(&config);
esp_err_t err = esp_http_client_perform(client);
if (err == ESP_OK) {
ESP_LOGI(TAG, "Status = %d, content_length = %d",
esp_http_client_get_status_code(client),
esp_http_client_get_content_length(client));
}
esp_http_client_cleanup(client);
}
HTTP Stream
Some applications need to open the connection and control the reading of the data in an active manner. the HTTP
client supports some functions to make this easier, of course, once you use these functions you should not use
the esp_http_client_perform() function with that handle, and esp_http_client_init() alway
to called first to get the handle. Perform that functions in the order below:
esp_http_client_init(): to create and handle
esp_http_client_set_* or esp_http_client_delete_*: to modify the http connection infor-
mation (optional)
esp_http_client_open(): Open the http connection with write_len parameter, write_len=0
if we only need read
Espressif Systems 559
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish