feat(esp_http_client): adds API to get transport socket

This commit is contained in:
Ashish Sharma
2026-01-21 17:04:13 +08:00
parent f4ad576689
commit 1e27eb204b
2 changed files with 22 additions and 2 deletions
+10 -1
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -2034,3 +2034,12 @@ bool esp_http_client_is_persistent_connection(esp_http_client_handle_t client)
}
return false;
}
int esp_http_client_get_socket(esp_http_client_handle_t client)
{
if (client == NULL || client->transport == NULL) {
return -1;
}
return esp_transport_get_socket(client->transport);
}
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -857,6 +857,17 @@ esp_err_t esp_http_client_get_chunk_length(esp_http_client_handle_t client, int
*/
bool esp_http_client_is_persistent_connection(esp_http_client_handle_t client);
/**
* @brief Get the socket from the underlying transport
*
* @param client The HTTP client handle
*
* @return
* - -1 if the client is NULL or the transport is not initialized
* - The socket file descriptor if successful
*/
int esp_http_client_get_socket(esp_http_client_handle_t client);
#ifdef __cplusplus
}
#endif