|
|
@@ -610,6 +610,8 @@ esp_http_client_handle_t esp_http_client_init(const esp_http_client_config_t *co
|
|
|
goto error;
|
|
|
}
|
|
|
|
|
|
+ const char *user_agent = config->user_agent == NULL ? DEFAULT_HTTP_USER_AGENT : config->user_agent;
|
|
|
+
|
|
|
if (config->host != NULL && config->path != NULL) {
|
|
|
host_name = _get_host_header(client->connection_info.host, client->connection_info.port);
|
|
|
if (host_name == NULL) {
|
|
|
@@ -617,7 +619,7 @@ esp_http_client_handle_t esp_http_client_init(const esp_http_client_config_t *co
|
|
|
goto error;
|
|
|
}
|
|
|
_success = (
|
|
|
- (esp_http_client_set_header(client, "User-Agent", DEFAULT_HTTP_USER_AGENT) == ESP_OK) &&
|
|
|
+ (esp_http_client_set_header(client, "User-Agent", user_agent) == ESP_OK) &&
|
|
|
(esp_http_client_set_header(client, "Host", host_name) == ESP_OK)
|
|
|
);
|
|
|
free(host_name);
|
|
|
@@ -637,7 +639,7 @@ esp_http_client_handle_t esp_http_client_init(const esp_http_client_config_t *co
|
|
|
}
|
|
|
|
|
|
_success = (
|
|
|
- (esp_http_client_set_header(client, "User-Agent", DEFAULT_HTTP_USER_AGENT) == ESP_OK) &&
|
|
|
+ (esp_http_client_set_header(client, "User-Agent", user_agent) == ESP_OK) &&
|
|
|
(esp_http_client_set_header(client, "Host", host_name) == ESP_OK)
|
|
|
);
|
|
|
|
|
|
@@ -721,6 +723,9 @@ esp_err_t esp_http_client_set_redirection(esp_http_client_handle_t client)
|
|
|
|
|
|
static esp_err_t esp_http_check_response(esp_http_client_handle_t client)
|
|
|
{
|
|
|
+ if (client->response->status_code >= HttpStatus_Ok && client->response->status_code < HttpStatus_MultipleChoices) {
|
|
|
+ return ESP_OK;
|
|
|
+ }
|
|
|
if (client->redirect_counter >= client->max_redirection_count || client->disable_auto_redirect) {
|
|
|
ESP_LOGE(TAG, "Error, reach max_redirection_count count=%d", client->redirect_counter);
|
|
|
return ESP_ERR_HTTP_MAX_REDIRECT;
|