mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
fix(esp_http_client): added initial argument checking for APIs'
This MR added checks for arguments passed in APIS' of esp_http_client.c
This commit is contained in:
parent
73e1085e54
commit
f9961fda62
@ -356,21 +356,37 @@ static int http_on_chunk_header(http_parser *parser)
|
||||
|
||||
esp_err_t esp_http_client_set_header(esp_http_client_handle_t client, const char *key, const char *value)
|
||||
{
|
||||
if (client == NULL || client->request == NULL || client->request->headers == NULL || key == NULL || value == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
return http_header_set(client->request->headers, key, value);
|
||||
}
|
||||
|
||||
esp_err_t esp_http_client_get_header(esp_http_client_handle_t client, const char *key, char **value)
|
||||
{
|
||||
if (client == NULL || client->request == NULL || client->request->headers == NULL || key == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
return http_header_get(client->request->headers, key, value);
|
||||
}
|
||||
|
||||
esp_err_t esp_http_client_delete_header(esp_http_client_handle_t client, const char *key)
|
||||
{
|
||||
if (client == NULL || client->request == NULL || client->request->headers == NULL || key == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
return http_header_delete(client->request->headers, key);
|
||||
}
|
||||
|
||||
esp_err_t esp_http_client_delete_headers(esp_http_client_handle_t client)
|
||||
esp_err_t esp_http_client_delete_all_headers(esp_http_client_handle_t client)
|
||||
{
|
||||
if (client == NULL || client->request == NULL || client->request->headers == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
return http_header_clean(client->request->headers);
|
||||
}
|
||||
|
||||
|
@ -496,7 +496,7 @@ esp_err_t esp_http_client_delete_header(esp_http_client_handle_t client, const c
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t esp_http_client_delete_headers(esp_http_client_handle_t client);
|
||||
esp_err_t esp_http_client_delete_all_headers(esp_http_client_handle_t client);
|
||||
|
||||
/**
|
||||
* @brief This function will be open the connection, write all header strings and return
|
||||
|
Loading…
x
Reference in New Issue
Block a user