mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 03:34:32 +02:00
Make the UserAgent string in esp-http-client configurable
Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com> Merges https://github.com/espressif/esp-idf/pull/6044
This commit is contained in:
committed by
Shubham Kulkarni
parent
aceb38c326
commit
8c09fbf6f1
@@ -610,6 +610,8 @@ esp_http_client_handle_t esp_http_client_init(const esp_http_client_config_t *co
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *user_agent = config->user_agent == NULL ? DEFAULT_HTTP_USER_AGENT : config->user_agent;
|
||||||
|
|
||||||
if (config->host != NULL && config->path != NULL) {
|
if (config->host != NULL && config->path != NULL) {
|
||||||
host_name = _get_host_header(client->connection_info.host, client->connection_info.port);
|
host_name = _get_host_header(client->connection_info.host, client->connection_info.port);
|
||||||
if (host_name == NULL) {
|
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;
|
goto error;
|
||||||
}
|
}
|
||||||
_success = (
|
_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)
|
(esp_http_client_set_header(client, "Host", host_name) == ESP_OK)
|
||||||
);
|
);
|
||||||
free(host_name);
|
free(host_name);
|
||||||
@@ -637,7 +639,7 @@ esp_http_client_handle_t esp_http_client_init(const esp_http_client_config_t *co
|
|||||||
}
|
}
|
||||||
|
|
||||||
_success = (
|
_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)
|
(esp_http_client_set_header(client, "Host", host_name) == ESP_OK)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -117,6 +117,7 @@ typedef struct {
|
|||||||
const char *cert_pem; /*!< SSL server certification, PEM format as string, if the client requires to verify server */
|
const char *cert_pem; /*!< SSL server certification, PEM format as string, if the client requires to verify server */
|
||||||
const char *client_cert_pem; /*!< SSL client certification, PEM format as string, if the server requires to verify client */
|
const char *client_cert_pem; /*!< SSL client certification, PEM format as string, if the server requires to verify client */
|
||||||
const char *client_key_pem; /*!< SSL client key, PEM format as string, if the server requires to verify client */
|
const char *client_key_pem; /*!< SSL client key, PEM format as string, if the server requires to verify client */
|
||||||
|
const char *user_agent; /*!< The User Agent string to send with HTTP requests */
|
||||||
esp_http_client_method_t method; /*!< HTTP Method */
|
esp_http_client_method_t method; /*!< HTTP Method */
|
||||||
int timeout_ms; /*!< Network timeout in milliseconds */
|
int timeout_ms; /*!< Network timeout in milliseconds */
|
||||||
bool disable_auto_redirect; /*!< Disable HTTP automatic redirects */
|
bool disable_auto_redirect; /*!< Disable HTTP automatic redirects */
|
||||||
|
Reference in New Issue
Block a user