Blame SOURCES/openscap-1.3.4-add_compression_tracing-PR_1561.patch

4def80
From aab536acdd4b08e2e8c3d4ac43981dfcaf1cc9f8 Mon Sep 17 00:00:00 2001
4def80
From: Evgeny Kolesnikov <ekolesni@redhat.com>
4def80
Date: Mon, 13 Jul 2020 14:09:52 +0200
4def80
Subject: [PATCH] Add CURLOPT_TRANSFER_ENCODING, enable CURLOPT_VERBOSE with
4def80
 CURLOPT_DEBUGFUNCTION
4def80
4def80
Adds a request for compressed Transfer Encoding in the outgoing
4def80
HTTP request. If the server supports this and so desires, it can
4def80
respond with the HTTP response sent using a compressed
4def80
Transfer-Encoding that will be automatically uncompressed by
4def80
libcurl on reception.
4def80
4def80
The CURLOPT_DEBUGFUNCTION callback is used for printing headers and
4def80
connection information on VERBOSE level (dD).
4def80
---
4def80
 src/common/oscap_acquire.c | 32 ++++++++++++++++++++++++++++++++
4def80
 1 file changed, 32 insertions(+)
4def80
4def80
diff --git a/src/common/oscap_acquire.c b/src/common/oscap_acquire.c
4def80
index 551da43f0..666f4f5c9 100644
4def80
--- a/src/common/oscap_acquire.c
4def80
+++ b/src/common/oscap_acquire.c
4def80
@@ -49,6 +49,7 @@
4def80
 #include "common/_error.h"
4def80
 #include "oscap_string.h"
4def80
 #include "oscap_helpers.h"
4def80
+#include "debug_priv.h"
4def80
 
4def80
 #ifndef OSCAP_TEMP_DIR
4def80
 #define OSCAP_TEMP_DIR "/tmp"
4def80
@@ -288,6 +289,34 @@ oscap_acquire_url_to_filename(const char *url)
4def80
 	return filename;
4def80
 }
4def80
 
4def80
+static int _curl_trace(CURL *handle, curl_infotype type, char *data, size_t size, void *userp)
4def80
+{
4def80
+	const char *title;
4def80
+
4def80
+	switch (type) {
4def80
+	case CURLINFO_TEXT:
4def80
+		title = "== cURL info";
4def80
+		break;
4def80
+	case CURLINFO_HEADER_OUT:
4def80
+		title = "=> cURL header (out)";
4def80
+		break;
4def80
+	case CURLINFO_HEADER_IN:
4def80
+		title = "<= cURL header (in)";
4def80
+		break;
4def80
+	case CURLINFO_DATA_OUT:
4def80
+	case CURLINFO_SSL_DATA_OUT:
4def80
+	case CURLINFO_DATA_IN:
4def80
+	case CURLINFO_SSL_DATA_IN:
4def80
+	default:
4def80
+		return 0;
4def80
+		break;
4def80
+	}
4def80
+
4def80
+	dD("%s: %s", title, data);
4def80
+
4def80
+	return 0;
4def80
+}
4def80
+
4def80
 char* oscap_acquire_url_download(const char *url, size_t* memory_size)
4def80
 {
4def80
 	CURL *curl;
4def80
@@ -303,7 +332,10 @@ char* oscap_acquire_url_download(const char *url, size_t* memory_size)
4def80
 	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_to_memory_callback);
4def80
 	curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer);
4def80
 	curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "");
4def80
+	curl_easy_setopt(curl, CURLOPT_TRANSFER_ENCODING, true);
4def80
 	curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
4def80
+	curl_easy_setopt(curl, CURLOPT_VERBOSE, true);
4def80
+	curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, _curl_trace);
4def80
 
4def80
 	CURLcode res = curl_easy_perform(curl);
4def80
 	curl_easy_cleanup(curl);