esp_http_client: Add support for getting transport type
This commit is contained in:
parent
fbe792f33f
commit
002189cd1a
|
@ -263,7 +263,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);
|
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.method = config->method;
|
||||||
client->connection_info.port = config->port;
|
client->connection_info.port = config->port;
|
||||||
|
@ -401,7 +401,7 @@ static esp_err_t esp_http_client_prepare(esp_http_client_handle_t client)
|
||||||
return ESP_OK;
|
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;
|
esp_http_client_handle_t client;
|
||||||
|
@ -983,3 +983,14 @@ bool esp_http_client_is_chunked_response(esp_http_client_handle_t client)
|
||||||
{
|
{
|
||||||
return client->response->is_chunked;
|
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`
|
* - `esp_http_client_handle_t`
|
||||||
* - NULL if any errors
|
* - 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
|
* @brief Invoke this function after `esp_http_client_init` and all the options calls are made, and will perform the
|
||||||
|
@ -334,6 +334,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);
|
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
|
#ifdef __cplusplus
|
||||||
|
@ -341,4 +352,4 @@ esp_err_t esp_http_client_cleanup(esp_http_client_handle_t client);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in a new issue