]> granicus.if.org Git - esp-idf/commitdiff
Add a `esp_http_client_set_redirection` function When using direct operations instead...
authorVikram Dattu <vikram.dattu@espressif.com>
Tue, 23 Apr 2019 13:53:20 +0000 (19:23 +0530)
committerVikram Dattu <vikram.dattu@espressif.com>
Tue, 23 Apr 2019 13:59:49 +0000 (19:29 +0530)
Signed-off-by: Vikram Dattu <vikram.dattu@espressif.com>
components/esp_http_client/esp_http_client.c
components/esp_http_client/include/esp_http_client.h

index ce93eae4be8b899df444f5e3904b436f5c5a683b..b2a58f725b691ed31037344f6ad6c6d81bd69239 100644 (file)
@@ -609,6 +609,17 @@ esp_err_t esp_http_client_cleanup(esp_http_client_handle_t client)
     return ESP_OK;
 }
 
+esp_err_t esp_http_client_set_redirection(esp_http_client_handle_t client)
+{
+    if (client == NULL) {
+        return ESP_ERR_INVALID_ARG;
+    }
+    if (client->location == NULL) {
+        return ESP_ERR_INVALID_ARG;
+    }
+    return esp_http_client_set_url(client, client->location);
+}
+
 static esp_err_t esp_http_check_response(esp_http_client_handle_t client)
 {
     char *auth_header = NULL;
index e4a9fba052a8f5f498f84cd455c73b784c27603a..102bf9e3ea24f54ae5062584f804c4e299e71f38 100644 (file)
@@ -406,6 +406,18 @@ esp_err_t esp_http_client_cleanup(esp_http_client_handle_t client);
  */
 esp_http_client_transport_t esp_http_client_get_transport_type(esp_http_client_handle_t client);
 
+/**
+ * @brief      Set redirection URL.
+ *             When received the 30x code from the server, the client stores the redirect URL provided by the server.
+ *             This function will set the current URL to redirect to enable client to execute the redirection request.
+ *
+ * @param[in]  client  The esp_http_client handle
+ *
+ * @return
+ *     - ESP_OK
+ *     - ESP_FAIL
+ */
+esp_err_t esp_http_client_set_redirection(esp_http_client_handle_t client);
 
 #ifdef __cplusplus
 }