Chapter 2. API Reference
• esp_http_client_write():
esp_http_client_open()
• esp_http_client_fetch_headers(): After sending the headers and write data (if any) to the server,
this function will read the HTTP Server response headers. Calling this function will return the content-
length from the Server, and we can call
status of the connection.
• esp_http_client_read(): Now, we can read the HTTP stream by this function.
• esp_http_client_close(): We should the connection after finish
• esp_http_client_cleanup(): And release the resources
Perform
HTTP
http_perform_as_stream_reader at protocols/esp_http_client.
HTTP Authentication
The HTTP client supports both Basic and Digest Authentication. By providing usernames and passwords in url or in
the username, password of config entry. And with auth_type = HTTP_AUTH_TYPE_BASIC, the HTTP
client takes only 1 perform to pass the authentication process. If auth_type = HTTP_AUTH_TYPE_NONE,
but there are username and password in the configuration, the HTTP client takes 2 performs. The first time it
connects to the server and receives the UNAUTHORIZED header. Based on this information, it will know which
authentication method to choose, and perform it on the second.
Config authentication example with URI
esp_http_client_config_t config
.url
=
"http://user:passwd@httpbin.org/basic-auth/user/passwd",
.auth_type
=
HTTP_AUTH_TYPE_BASIC,
};
Config authentication example with username, password entry
esp_http_client_config_t config
.url
=
"http://httpbin.org/basic-auth/user/passwd",
.username
=
"user",
.password
=
"passwd",
.auth_type
=
HTTP_AUTH_TYPE_BASIC,
};
HTTP Client example: protocols/esp_http_client.
API Reference
Header File
•
components/esp_http_client/include/esp_http_client.h
Functions
esp_http_client_handle_t
esp_http_client_init(const
Start a HTTP session This function must be the first function to call, and it returns a esp_http_client_handle_t
that you must use as input to other functions in the interface. This call MUST have a corresponding call to
esp_http_client_cleanup when the operation is complete.
Return
• esp_http_client_handle_t
• NULL if any errors
Parameters
• [in] config: The configurations, see http_client_config_t
Espressif Systems
Upload
function. We may not need to call it if write_len=0
esp_http_client_get_status_code()
request
as
Stream
=
{
=
{
Submit Document Feedback
data,
max
length
reader
Check
esp_http_client_config_t
560
equal
to
write_len
for the HTTP
the
example
function
*config)
Release v4.4
of
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?