mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_http_client: Add support for getting transport type
This commit is contained in:
parent
1fecdc3891
commit
2d79af3b13
@ -278,7 +278,7 @@ esp_err_t esp_http_client_delete_header(esp_http_client_handle_t client, const c
|
||||
return http_header_delete(client->request->headers, key);
|
||||
}
|
||||
|
||||
static esp_err_t _set_config(esp_http_client_handle_t client, esp_http_client_config_t *config)
|
||||
static esp_err_t _set_config(esp_http_client_handle_t client, const esp_http_client_config_t *config)
|
||||
{
|
||||
client->connection_info.method = config->method;
|
||||
client->connection_info.port = config->port;
|
||||
@ -416,7 +416,7 @@ static esp_err_t esp_http_client_prepare(esp_http_client_handle_t client)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_http_client_handle_t esp_http_client_init(esp_http_client_config_t *config)
|
||||
esp_http_client_handle_t esp_http_client_init(const esp_http_client_config_t *config)
|
||||
{
|
||||
|
||||
esp_http_client_handle_t client;
|
||||
@ -1011,3 +1011,14 @@ bool esp_http_client_is_chunked_response(esp_http_client_handle_t client)
|
||||
{
|
||||
return client->response->is_chunked;
|
||||
}
|
||||
|
||||
esp_http_client_transport_t esp_http_client_get_transport_type(esp_http_client_handle_t client)
|
||||
{
|
||||
if (!strcmp(client->connection_info.scheme, "https") ) {
|
||||
return HTTP_TRANSPORT_OVER_SSL;
|
||||
} else if (!strcmp(client->connection_info.scheme, "http")) {
|
||||
return HTTP_TRANSPORT_OVER_TCP;
|
||||
} else {
|
||||
return HTTP_TRANSPORT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ typedef struct {
|
||||
* - `esp_http_client_handle_t`
|
||||
* - NULL if any errors
|
||||
*/
|
||||
esp_http_client_handle_t esp_http_client_init(esp_http_client_config_t *config);
|
||||
esp_http_client_handle_t esp_http_client_init(const esp_http_client_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Invoke this function after `esp_http_client_init` and all the options calls are made, and will perform the
|
||||
@ -350,6 +350,17 @@ esp_err_t esp_http_client_close(esp_http_client_handle_t client);
|
||||
*/
|
||||
esp_err_t esp_http_client_cleanup(esp_http_client_handle_t client);
|
||||
|
||||
/**
|
||||
* @brief Get transport type
|
||||
*
|
||||
* @param[in] client The esp_http_client handle
|
||||
*
|
||||
* @return
|
||||
* - HTTP_TRANSPORT_UNKNOWN
|
||||
* - HTTP_TRANSPORT_OVER_TCP
|
||||
* - HTTP_TRANSPORT_OVER_SSL
|
||||
*/
|
||||
esp_http_client_transport_t esp_http_client_get_transport_type(esp_http_client_handle_t client);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -357,4 +368,4 @@ esp_err_t esp_http_client_cleanup(esp_http_client_handle_t client);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user