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

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