diff mbox series

[06/14] channel_curl: put: use log function, respect nocheckanswer

Message ID 20200914145712.4989-6-christian.storm@siemens.com
State Accepted
Headers show
Series [01/14] channel_curl: Make setting request_body symmetric | expand

Commit Message

Storm, Christian Sept. 14, 2020, 2:57 p.m. UTC
Make channel_put_method() use the factored out log function
like channel_post_method() and channel_get() do.

Also respect nocheckanswer.

Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 corelib/channel_curl.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Stefano Babic Sept. 17, 2020, 1:41 p.m. UTC | #1
On 14.09.20 16:57, Christian Storm wrote:
> Make channel_put_method() use the factored out log function
> like channel_post_method() and channel_get() do.
> 
> Also respect nocheckanswer.
> 
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>  corelib/channel_curl.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
> index 40c8c60..27d4b62 100644
> --- a/corelib/channel_curl.c
> +++ b/corelib/channel_curl.c
> @@ -722,7 +722,7 @@ static void channel_log_reply(channel_op_res_t result, channel_data_t *channel_d
>  			case 403:
>  			case 404:
>  			case 500:
> -				DEBUG("The error message is: '%s'", chunk->memory);
> +				DEBUG("The error message is: '%s'", chunk ? chunk->memory : "N/A");
>  				break;
>  			default:
>  				break;
> @@ -893,13 +893,11 @@ static channel_op_res_t channel_put_method(channel_t *this, void *data)
>  	channel_log_effective_url(this);
>  
>  	result = channel_map_http_code(this, &channel_data->http_response_code);
> -	if (result != CHANNEL_OK) {
> -		ERROR("Channel operation returned HTTP error code %ld.",
> -		      channel_data->http_response_code);
> +
> +	if (channel_data->nocheckanswer)
>  		goto cleanup_header;
> -	}
> -	TRACE("Channel put operation returned HTTP error code %ld.",
> -	      channel_data->http_response_code);
> +
> +	channel_log_reply(result, channel_data, NULL);
>  
>  cleanup_header:
>  	curl_easy_reset(channel_curl->handle);
> 

Reviewed-by: Stefano Babic <ababic@denx.de>

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
index 40c8c60..27d4b62 100644
--- a/corelib/channel_curl.c
+++ b/corelib/channel_curl.c
@@ -722,7 +722,7 @@  static void channel_log_reply(channel_op_res_t result, channel_data_t *channel_d
 			case 403:
 			case 404:
 			case 500:
-				DEBUG("The error message is: '%s'", chunk->memory);
+				DEBUG("The error message is: '%s'", chunk ? chunk->memory : "N/A");
 				break;
 			default:
 				break;
@@ -893,13 +893,11 @@  static channel_op_res_t channel_put_method(channel_t *this, void *data)
 	channel_log_effective_url(this);
 
 	result = channel_map_http_code(this, &channel_data->http_response_code);
-	if (result != CHANNEL_OK) {
-		ERROR("Channel operation returned HTTP error code %ld.",
-		      channel_data->http_response_code);
+
+	if (channel_data->nocheckanswer)
 		goto cleanup_header;
-	}
-	TRACE("Channel put operation returned HTTP error code %ld.",
-	      channel_data->http_response_code);
+
+	channel_log_reply(result, channel_data, NULL);
 
 cleanup_header:
 	curl_easy_reset(channel_curl->handle);