11/*
2- * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+ * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 */
@@ -255,7 +255,7 @@ static int http_on_header_field(http_parser *parser, const char *at, size_t leng
255255{
256256 esp_http_client_t * client = parser -> data ;
257257 http_on_header_event (client );
258- ESP_RETURN_ON_FALSE_DEBUG (http_utils_append_string (& client -> current_header_key , at , length ), -1 , TAG , "Failed to append string" );
258+ HTTP_RET_ON_FALSE_DBG (http_utils_append_string (& client -> current_header_key , at , length ), -1 , TAG , "Failed to append string" );
259259
260260 return 0 ;
261261}
@@ -267,14 +267,14 @@ static int http_on_header_value(http_parser *parser, const char *at, size_t leng
267267 return 0 ;
268268 }
269269 if (strcasecmp (client -> current_header_key , "Location" ) == 0 ) {
270- ESP_RETURN_ON_FALSE_DEBUG (http_utils_append_string (& client -> location , at , length ), -1 , TAG , "Failed to append string" );
270+ HTTP_RET_ON_FALSE_DBG (http_utils_append_string (& client -> location , at , length ), -1 , TAG , "Failed to append string" );
271271 } else if (strcasecmp (client -> current_header_key , "Transfer-Encoding" ) == 0
272272 && memcmp (at , "chunked" , length ) == 0 ) {
273273 client -> response -> is_chunked = true;
274274 } else if (strcasecmp (client -> current_header_key , "WWW-Authenticate" ) == 0 ) {
275- ESP_RETURN_ON_FALSE_DEBUG (http_utils_append_string (& client -> auth_header , at , length ), -1 , TAG , "Failed to append string" );
275+ HTTP_RET_ON_FALSE_DBG (http_utils_append_string (& client -> auth_header , at , length ), -1 , TAG , "Failed to append string" );
276276 }
277- ESP_RETURN_ON_FALSE_DEBUG (http_utils_append_string (& client -> current_header_value , at , length ), -1 , TAG , "Failed to append string" );
277+ HTTP_RET_ON_FALSE_DBG (http_utils_append_string (& client -> current_header_value , at , length ), -1 , TAG , "Failed to append string" );
278278 return 0 ;
279279}
280280
@@ -554,12 +554,12 @@ static esp_err_t _set_config(esp_http_client_handle_t client, const esp_http_cli
554554 }
555555
556556 if (config -> transport_type == HTTP_TRANSPORT_OVER_SSL ) {
557- ESP_GOTO_ON_FALSE_DEBUG (http_utils_assign_string (& client -> connection_info .scheme , "https" , -1 ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
557+ HTTP_GOTO_ON_FALSE_DBG (http_utils_assign_string (& client -> connection_info .scheme , "https" , -1 ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
558558 if (client -> connection_info .port == 0 ) {
559559 client -> connection_info .port = DEFAULT_HTTPS_PORT ;
560560 }
561561 } else {
562- ESP_GOTO_ON_FALSE_DEBUG (http_utils_assign_string (& client -> connection_info .scheme , "http" , -1 ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
562+ HTTP_GOTO_ON_FALSE_DBG (http_utils_assign_string (& client -> connection_info .scheme , "http" , -1 ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
563563 if (client -> connection_info .port == 0 ) {
564564 client -> connection_info .port = DEFAULT_HTTP_PORT ;
565565 }
@@ -639,11 +639,11 @@ static esp_err_t esp_http_client_prepare_digest_auth(esp_http_client_handle_t cl
639639 // Freeing the allocated memory for auth_data->uri and setting it to NULL to prevent potential memory leaks
640640 free (client -> auth_data -> uri );
641641 client -> auth_data -> uri = NULL ;
642- ESP_GOTO_ON_FALSE_DEBUG (http_utils_assign_string (& client -> auth_data -> uri , client -> connection_info .path , -1 ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
642+ HTTP_GOTO_ON_FALSE_DBG (http_utils_assign_string (& client -> auth_data -> uri , client -> connection_info .path , -1 ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
643643
644644 if (client -> connection_info .query ) {
645- ESP_GOTO_ON_FALSE_DEBUG (http_utils_append_string (& client -> auth_data -> uri , "?" , -1 ), ESP_ERR_NO_MEM , error , TAG , "Failed to append string" );
646- ESP_GOTO_ON_FALSE_DEBUG (http_utils_append_string (& client -> auth_data -> uri , client -> connection_info .query , -1 ), ESP_ERR_NO_MEM , error , TAG , "Failed to append string" );
645+ HTTP_GOTO_ON_FALSE_DBG (http_utils_append_string (& client -> auth_data -> uri , "?" , -1 ), ESP_ERR_NO_MEM , error , TAG , "Failed to append string" );
646+ HTTP_GOTO_ON_FALSE_DBG (http_utils_append_string (& client -> auth_data -> uri , client -> connection_info .query , -1 ), ESP_ERR_NO_MEM , error , TAG , "Failed to append string" );
647647 }
648648
649649 client -> auth_data -> cnonce = ((uint64_t )esp_random () << 32 ) + esp_random ();
@@ -1101,7 +1101,7 @@ esp_err_t esp_http_client_set_url(esp_http_client_handle_t client, const char *u
11011101 old_port = client -> connection_info .port ;
11021102
11031103 if (purl .field_data [UF_HOST ].len ) {
1104- ESP_GOTO_ON_FALSE_DEBUG (http_utils_assign_string (& client -> connection_info .host , url + purl .field_data [UF_HOST ].off , purl .field_data [UF_HOST ].len ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
1104+ HTTP_GOTO_ON_FALSE_DBG (http_utils_assign_string (& client -> connection_info .host , url + purl .field_data [UF_HOST ].off , purl .field_data [UF_HOST ].len ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
11051105 }
11061106 // Close the connection if host was changed
11071107 if (old_host && client -> connection_info .host
@@ -1122,7 +1122,7 @@ esp_err_t esp_http_client_set_url(esp_http_client_handle_t client, const char *u
11221122 }
11231123
11241124 if (purl .field_data [UF_SCHEMA ].len ) {
1125- ESP_GOTO_ON_FALSE_DEBUG (http_utils_assign_string (& client -> connection_info .scheme , url + purl .field_data [UF_SCHEMA ].off , purl .field_data [UF_SCHEMA ].len ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
1125+ HTTP_GOTO_ON_FALSE_DBG (http_utils_assign_string (& client -> connection_info .scheme , url + purl .field_data [UF_SCHEMA ].off , purl .field_data [UF_SCHEMA ].len ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
11261126
11271127 if (strcasecmp (client -> connection_info .scheme , "http" ) == 0 ) {
11281128 client -> connection_info .port = DEFAULT_HTTP_PORT ;
@@ -1143,16 +1143,16 @@ esp_err_t esp_http_client_set_url(esp_http_client_handle_t client, const char *u
11431143
11441144 if (purl .field_data [UF_USERINFO ].len ) {
11451145 char * user_info = NULL ;
1146- ESP_GOTO_ON_FALSE_DEBUG (http_utils_assign_string (& user_info , url + purl .field_data [UF_USERINFO ].off , purl .field_data [UF_USERINFO ].len ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
1146+ HTTP_GOTO_ON_FALSE_DBG (http_utils_assign_string (& user_info , url + purl .field_data [UF_USERINFO ].off , purl .field_data [UF_USERINFO ].len ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
11471147 if (user_info ) {
11481148 char * username = user_info ;
11491149 char * password = strchr (user_info , ':' );
11501150 if (password ) {
11511151 * password = 0 ;
11521152 password ++ ;
1153- ESP_GOTO_ON_FALSE_DEBUG (http_utils_assign_string (& client -> connection_info .password , password , -1 ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
1153+ HTTP_GOTO_ON_FALSE_DBG (http_utils_assign_string (& client -> connection_info .password , password , -1 ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
11541154 }
1155- ESP_GOTO_ON_FALSE_DEBUG (http_utils_assign_string (& client -> connection_info .username , username , -1 ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
1155+ HTTP_GOTO_ON_FALSE_DBG (http_utils_assign_string (& client -> connection_info .username , username , -1 ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
11561156 free (user_info );
11571157 } else {
11581158 return ESP_ERR_NO_MEM ;
@@ -1161,13 +1161,13 @@ esp_err_t esp_http_client_set_url(esp_http_client_handle_t client, const char *u
11611161
11621162 //Reset path and query if there are no information
11631163 if (purl .field_data [UF_PATH ].len ) {
1164- ESP_GOTO_ON_FALSE_DEBUG (http_utils_assign_string (& client -> connection_info .path , url + purl .field_data [UF_PATH ].off , purl .field_data [UF_PATH ].len ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
1164+ HTTP_GOTO_ON_FALSE_DBG (http_utils_assign_string (& client -> connection_info .path , url + purl .field_data [UF_PATH ].off , purl .field_data [UF_PATH ].len ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
11651165 } else {
1166- ESP_GOTO_ON_FALSE_DEBUG (http_utils_assign_string (& client -> connection_info .path , "/" , -1 ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
1166+ HTTP_GOTO_ON_FALSE_DBG (http_utils_assign_string (& client -> connection_info .path , "/" , -1 ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
11671167 }
11681168
11691169 if (purl .field_data [UF_QUERY ].len ) {
1170- ESP_GOTO_ON_FALSE_DEBUG (http_utils_assign_string (& client -> connection_info .query , url + purl .field_data [UF_QUERY ].off , purl .field_data [UF_QUERY ].len ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
1170+ HTTP_GOTO_ON_FALSE_DBG (http_utils_assign_string (& client -> connection_info .query , url + purl .field_data [UF_QUERY ].off , purl .field_data [UF_QUERY ].len ), ESP_ERR_NO_MEM , error , TAG , "failed to assign string" );
11711171 } else if (client -> connection_info .query ) {
11721172 free (client -> connection_info .query );
11731173 client -> connection_info .query = NULL ;
@@ -1792,7 +1792,7 @@ esp_err_t esp_http_client_set_auth_data(esp_http_client_handle_t client, const c
17921792 if (client == NULL || auth_data == NULL || len <= 0 ) {
17931793 return ESP_ERR_INVALID_ARG ;
17941794 }
1795- ESP_RETURN_ON_FALSE_DEBUG (http_utils_append_string (& client -> auth_header , auth_data , len ), ESP_ERR_NO_MEM , TAG , "Failed to append string" );
1795+ HTTP_RET_ON_FALSE_DBG (http_utils_append_string (& client -> auth_header , auth_data , len ), ESP_ERR_NO_MEM , TAG , "Failed to append string" );
17961796 return ESP_OK ;
17971797}
17981798
@@ -1841,20 +1841,20 @@ esp_err_t esp_http_client_add_auth(esp_http_client_handle_t client)
18411841 client -> auth_data -> method = strdup (HTTP_METHOD_MAPPING [client -> connection_info .method ]);
18421842
18431843 client -> auth_data -> nc = 1 ;
1844- ESP_RETURN_ON_ERROR_DEBUG (http_utils_get_substring_between (auth_header , "realm=\"" , "\"" , & client -> auth_data -> realm ), TAG , "Unable to extract substring between specified strings" );
1845- ESP_RETURN_ON_ERROR_DEBUG (http_utils_get_substring_between (auth_header , "algorithm=" , "," , & client -> auth_data -> algorithm ), TAG , "Unable to extract substring between specified strings" );
1844+ HTTP_RET_ON_ERR_DBG (http_utils_get_substring_between (auth_header , "realm=\"" , "\"" , & client -> auth_data -> realm ), TAG , "Unable to extract substring between specified strings" );
1845+ HTTP_RET_ON_ERR_DBG (http_utils_get_substring_between (auth_header , "algorithm=" , "," , & client -> auth_data -> algorithm ), TAG , "Unable to extract substring between specified strings" );
18461846
18471847 if (client -> auth_data -> algorithm == NULL ) {
1848- ESP_RETURN_ON_ERROR_DEBUG (http_utils_get_substring_after (auth_header , "algorithm=" , & client -> auth_data -> algorithm ), TAG , "Unable to extract substring after specified string" );
1848+ HTTP_RET_ON_ERR_DBG (http_utils_get_substring_after (auth_header , "algorithm=" , & client -> auth_data -> algorithm ), TAG , "Unable to extract substring after specified string" );
18491849 }
18501850
18511851 if (client -> auth_data -> algorithm == NULL ) {
18521852 client -> auth_data -> algorithm = strdup ("MD5" );
18531853 }
18541854
1855- ESP_RETURN_ON_ERROR_DEBUG (http_utils_get_substring_between (auth_header , "qop=\"" , "\"" , & client -> auth_data -> qop ), TAG , "Unable to extract substring between specified strings" );
1856- ESP_RETURN_ON_ERROR_DEBUG (http_utils_get_substring_between (auth_header , "nonce=\"" , "\"" , & client -> auth_data -> nonce ), TAG , "Unable to extract substring between specified strings" );
1857- ESP_RETURN_ON_ERROR_DEBUG (http_utils_get_substring_between (auth_header , "opaque=\"" , "\"" , & client -> auth_data -> opaque ), TAG , "Unable to extract substring between specified strings" );
1855+ HTTP_RET_ON_ERR_DBG (http_utils_get_substring_between (auth_header , "qop=\"" , "\"" , & client -> auth_data -> qop ), TAG , "Unable to extract substring between specified strings" );
1856+ HTTP_RET_ON_ERR_DBG (http_utils_get_substring_between (auth_header , "nonce=\"" , "\"" , & client -> auth_data -> nonce ), TAG , "Unable to extract substring between specified strings" );
1857+ HTTP_RET_ON_ERR_DBG (http_utils_get_substring_between (auth_header , "opaque=\"" , "\"" , & client -> auth_data -> opaque ), TAG , "Unable to extract substring between specified strings" );
18581858 client -> process_again = 1 ;
18591859
18601860 return ESP_OK ;
0 commit comments