diff mbox series

[02/14,V2] channel_curl: Consolidate curl verbose setting

Message ID 20200921085920.16382-1-christian.storm@siemens.com
State Accepted
Headers show
Series None | expand

Commit Message

Storm, Christian Sept. 21, 2020, 8:59 a.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(-)
diff mbox series

Patch

diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
index 02d8dff..e6af2c4 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) {
+		(void)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) {