mirror of
https://github.com/espressif/esp-idf.git
synced 2024-09-19 14:26:01 -04:00
Merge branch 'feat/add_support_to_add_auth_data' into 'master'
feat(esp_http_client): Add API to set auth data Closes IDFGH-10936 See merge request espressif/esp-idf!25884
This commit is contained in:
commit
e95849880e
@ -233,7 +233,6 @@ static int http_on_header_event(esp_http_client_handle_t client)
|
||||
static int http_on_header_field(http_parser *parser, const char *at, size_t length)
|
||||
{
|
||||
esp_http_client_t *client = parser->data;
|
||||
http_on_header_event(client);
|
||||
http_utils_append_string(&client->current_header_key, at, length);
|
||||
|
||||
return 0;
|
||||
@ -254,6 +253,7 @@ static int http_on_header_value(http_parser *parser, const char *at, size_t leng
|
||||
http_utils_append_string(&client->auth_header, at, length);
|
||||
}
|
||||
http_utils_append_string(&client->current_header_value, at, length);
|
||||
http_on_header_event(client);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
@ -600,6 +600,21 @@ esp_http_client_transport_t esp_http_client_get_transport_type(esp_http_client_h
|
||||
*/
|
||||
esp_err_t esp_http_client_set_redirection(esp_http_client_handle_t client);
|
||||
|
||||
/**
|
||||
* @brief On receiving a custom authentication header, this API can be invoked to set the
|
||||
* authentication information from the header. This API can be called from the event
|
||||
* handler.
|
||||
*
|
||||
* @param[in] client The esp_http_client handle
|
||||
* @param[in] auth_data The authentication data received in the header
|
||||
* @param[in] len length of auth_data.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t esp_http_client_set_auth_data(esp_http_client_handle_t client, const char *auth_data, int len);
|
||||
|
||||
/**
|
||||
* @brief On receiving HTTP Status code 401, this API can be invoked to add authorization
|
||||
* information.
|
||||
|
Loading…
Reference in New Issue
Block a user