Merge branch 'feature/get_url' into 'master'
Add API to get URL from HTTP client Closes IDFGH-3094 See merge request espressif/esp-idf!8637
This commit is contained in:
commit
d7fb9d54ba
2 changed files with 28 additions and 0 deletions
|
@ -1332,3 +1332,17 @@ int esp_http_client_read_response(esp_http_client_handle_t client, char *buffer,
|
|||
}
|
||||
return read_len;
|
||||
}
|
||||
|
||||
esp_err_t esp_http_client_get_url(esp_http_client_handle_t client, char *url, const int len)
|
||||
{
|
||||
if (client == NULL || url == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (client->connection_info.host && client->connection_info.scheme && client->connection_info.path) {
|
||||
snprintf(url, len, "%s://%s%s", client->connection_info.scheme, client->connection_info.host, client->connection_info.path);
|
||||
return ESP_OK;
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to get URL");
|
||||
}
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
|
|
@ -511,6 +511,20 @@ bool esp_http_client_is_complete_data_received(esp_http_client_handle_t client);
|
|||
|
||||
int esp_http_client_read_response(esp_http_client_handle_t client, char *buffer, int len);
|
||||
|
||||
/**
|
||||
* @brief Get URL from client
|
||||
*
|
||||
* @param[in] client The esp_http_client handle
|
||||
* @param[inout] url The buffer to store URL
|
||||
* @param[in] len The buffer length
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
|
||||
esp_err_t esp_http_client_get_url(esp_http_client_handle_t client, char *url, const int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue