feat(esp_http_client): Add API to set auth data

This new API can be used to set the authentication data in the client context
when the auth data is received in the custom header

Closes: https://github.com/espressif/esp-idf/pull/12131
This commit is contained in:
Harshit Malpani
2023-09-08 14:03:04 +05:30
parent 3b7a37fcd4
commit 96a8316e71
2 changed files with 24 additions and 0 deletions

View File

@@ -1645,6 +1645,15 @@ esp_http_client_transport_t esp_http_client_get_transport_type(esp_http_client_h
}
}
esp_err_t esp_http_client_set_auth_data(esp_http_client_handle_t client, const char *auth_data, int len)
{
if (client == NULL || auth_data == NULL || len <= 0) {
return ESP_ERR_INVALID_ARG;
}
http_utils_append_string(&client->auth_header, auth_data, len);
return ESP_OK;
}
void esp_http_client_add_auth(esp_http_client_handle_t client)
{
if (client == NULL) {