diff mbox series

[02/14] channel_curl: Consolidate curl verbose setting

Message ID 20200914145712.4989-2-christian.storm@siemens.com
State Changes Requested
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
Centralize the curl call to enable VERBOSE curl mode to
channel_set_options() instead of the channel_<verb> methods.

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

Comments

Stefano Babic Sept. 15, 2020, 9:07 a.m. UTC | #1
On 14.09.20 16:57, Christian Storm wrote:
> Centralize the curl call to enable VERBOSE curl mode to
> channel_set_options() instead of the channel_<verb> methods.
> 
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>  corelib/channel_curl.c | 19 ++++---------------
>  1 file changed, 4 insertions(+), 15 deletions(-)
> 
> diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
> index 02d8dff..ec65581 100644
> --- a/corelib/channel_curl.c
> +++ b/corelib/channel_curl.c
> @@ -514,6 +514,10 @@ channel_op_res_t channel_set_options(channel_t *this,
>  		goto cleanup;
>  	}
>  
> +	if (channel_data->debug) {
> +		curl_easy_setopt(channel_curl->handle, CURLOPT_VERBOSE, 1L);
> +	}
> +
>  	if ((!channel_data->nofollow) &&
>  	    (curl_easy_setopt(channel_curl->handle, CURLOPT_FOLLOWLOCATION, 1) !=
>  	     CURLE_OK)) {
> @@ -717,10 +721,6 @@ static channel_op_res_t channel_post_method(channel_t *this, void *data)
>  	channel_op_res_t result = CHANNEL_OK;
>  	channel_data_t *channel_data = (channel_data_t *)data;
>  
> -	if (channel_data->debug) {
> -		curl_easy_setopt(channel_curl->handle, CURLOPT_VERBOSE, 1L);
> -	}
> -
>  	if ((result = channel_set_content_type(this, channel_data)) !=
>  	    CHANNEL_OK) {
>  		ERROR("Set content-type option failed.");
> @@ -783,10 +783,6 @@ static channel_op_res_t channel_put_method(channel_t *this, void *data)
>  	channel_data_t *channel_data = (channel_data_t *)data;
>  	channel_data->offs = 0;
>  
> -	if (channel_data->debug) {
> -		curl_easy_setopt(channel_curl->handle, CURLOPT_VERBOSE, 1L);
> -	}
> -
>  	if ((result = channel_set_content_type(this, channel_data)) !=
>  	    CHANNEL_OK) {
>  		ERROR("Set content-type option failed.");
> @@ -875,10 +871,6 @@ channel_op_res_t channel_get_file(channel_t *this, void *data)
>  		}
>  	}
>  
> -	if (channel_data->debug) {
> -		curl_easy_setopt(channel_curl->handle, CURLOPT_VERBOSE, 1L);
> -	}
> -
>  	if (((channel_curl->header = curl_slist_append(
>  		  channel_curl->header,
>  		  "Content-Type: application/octet-stream")) == NULL) ||
> @@ -1064,9 +1056,6 @@ channel_op_res_t channel_get(channel_t *this, void *data)
>  	channel_data_t *channel_data = (channel_data_t *)data;
>  	channel_data->http_response_code = 0;
>  
> -	if (channel_data->debug) {
> -		curl_easy_setopt(channel_curl->handle, CURLOPT_VERBOSE, 1L);
> -	}
>  
>  	if ((result = channel_set_content_type(this, channel_data)) !=
>  	    CHANNEL_OK) {
> 

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

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
index 02d8dff..ec65581 100644
--- a/corelib/channel_curl.c
+++ b/corelib/channel_curl.c
@@ -514,6 +514,10 @@  channel_op_res_t channel_set_options(channel_t *this,
 		goto cleanup;
 	}
 
+	if (channel_data->debug) {
+		curl_easy_setopt(channel_curl->handle, CURLOPT_VERBOSE, 1L);
+	}
+
 	if ((!channel_data->nofollow) &&
 	    (curl_easy_setopt(channel_curl->handle, CURLOPT_FOLLOWLOCATION, 1) !=
 	     CURLE_OK)) {
@@ -717,10 +721,6 @@  static channel_op_res_t channel_post_method(channel_t *this, void *data)
 	channel_op_res_t result = CHANNEL_OK;
 	channel_data_t *channel_data = (channel_data_t *)data;
 
-	if (channel_data->debug) {
-		curl_easy_setopt(channel_curl->handle, CURLOPT_VERBOSE, 1L);
-	}
-
 	if ((result = channel_set_content_type(this, channel_data)) !=
 	    CHANNEL_OK) {
 		ERROR("Set content-type option failed.");
@@ -783,10 +783,6 @@  static channel_op_res_t channel_put_method(channel_t *this, void *data)
 	channel_data_t *channel_data = (channel_data_t *)data;
 	channel_data->offs = 0;
 
-	if (channel_data->debug) {
-		curl_easy_setopt(channel_curl->handle, CURLOPT_VERBOSE, 1L);
-	}
-
 	if ((result = channel_set_content_type(this, channel_data)) !=
 	    CHANNEL_OK) {
 		ERROR("Set content-type option failed.");
@@ -875,10 +871,6 @@  channel_op_res_t channel_get_file(channel_t *this, void *data)
 		}
 	}
 
-	if (channel_data->debug) {
-		curl_easy_setopt(channel_curl->handle, CURLOPT_VERBOSE, 1L);
-	}
-
 	if (((channel_curl->header = curl_slist_append(
 		  channel_curl->header,
 		  "Content-Type: application/octet-stream")) == NULL) ||
@@ -1064,9 +1056,6 @@  channel_op_res_t channel_get(channel_t *this, void *data)
 	channel_data_t *channel_data = (channel_data_t *)data;
 	channel_data->http_response_code = 0;
 
-	if (channel_data->debug) {
-		curl_easy_setopt(channel_curl->handle, CURLOPT_VERBOSE, 1L);
-	}
 
 	if ((result = channel_set_content_type(this, channel_data)) !=
 	    CHANNEL_OK) {