Add user_data accessor and mutator to esp_http_client

Closes: https://github.com/espressif/esp-idf/pull/10715
pull/11041/head
Andrew Clink 2023-02-06 15:44:19 -07:00 zatwierdzone przez Harshit Malpani
rodzic d29e53dc0c
commit 82cdcc5de5
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: FF1193D150EF75C3
2 zmienionych plików z 50 dodań i 0 usunięć

Wyświetl plik

@ -413,6 +413,28 @@ esp_err_t esp_http_client_set_authtype(esp_http_client_handle_t client, esp_http
return ESP_OK;
}
esp_err_t esp_http_client_get_user_data(esp_http_client_handle_t client, void **data)
{
if (NULL == client || NULL == data) {
ESP_LOGE(TAG, "client or data must not be NULL");
return ESP_ERR_INVALID_ARG;
}
*data = client->user_data;
return ESP_OK;
}
esp_err_t esp_http_client_set_user_data(esp_http_client_handle_t client, void *data)
{
if (NULL == client) {
ESP_LOGE(TAG, "client must not be NULL");
return ESP_ERR_INVALID_ARG;
}
client->user_data = data;
return ESP_OK;
}
static esp_err_t _set_config(esp_http_client_handle_t client, const esp_http_client_config_t *config)
{
esp_err_t ret = ESP_OK;

Wyświetl plik

@ -364,6 +364,34 @@ esp_err_t esp_http_client_set_password(esp_http_client_handle_t client, const ch
*/
esp_err_t esp_http_client_set_authtype(esp_http_client_handle_t client, esp_http_client_auth_type_t auth_type);
/**
* @brief Get http request user_data.
* The value stored from the esp_http_client_config_t will be written
* to the address passed into data.
*
* @param[in] client The esp_http_client handle
* @param[out] data A pointer to the pointer that will be set to user_data.
*
* @return
* - ESP_OK
* - ESP_ERR_INVALID_ARG
*/
esp_err_t esp_http_client_get_user_data(esp_http_client_handle_t client, void **data);
/**
* @brief Set http request user_data.
* The value passed in +data+ will be available during event callbacks.
* No memory management will be performed on the user's behalf.
*
* @param[in] client The esp_http_client handle
* @param[in] data The pointer to the user data
*
* @return
* - ESP_OK
* - ESP_ERR_INVALID_ARG
*/
esp_err_t esp_http_client_set_user_data(esp_http_client_handle_t client, void *data);
/**
* @brief Get HTTP client session errno
*