[llvm] [Debuginfod] Accept compressed encodings in client (PR #68055)

Daniel Thornburgh via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 17:00:57 PDT 2023


https://github.com/mysterymath created https://github.com/llvm/llvm-project/pull/68055

All encodings that the underlying libcurl supports are automatically detected and accepted. libcurl will then decompress on the fly. This improves effective network transfer rate and prevents server-side decompression for files stored compressed.

Fixes #63534

>From e600168772cf2fb0ce2744bf4d66841cb6776d8d Mon Sep 17 00:00:00 2001
From: Daniel Thornburgh <dthorn at google.com>
Date: Mon, 2 Oct 2023 16:56:28 -0700
Subject: [PATCH] [Debuginfod] Accept compressed encodings in client

All encodings that the underlying libcurl supports are automatically
detected and accepted. libcurl will then decompress on the fly. This
improves effective network transfer rate and prevents server-side
decompression for files stored compressed.

Fixes #63534
---
 llvm/lib/Debuginfod/HTTPClient.cpp                | 2 ++
 llvm/test/tools/llvm-debuginfod-find/headers.test | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/llvm/lib/Debuginfod/HTTPClient.cpp b/llvm/lib/Debuginfod/HTTPClient.cpp
index f9201e4f96268c1..4cca250746a597c 100644
--- a/llvm/lib/Debuginfod/HTTPClient.cpp
+++ b/llvm/lib/Debuginfod/HTTPClient.cpp
@@ -97,6 +97,8 @@ HTTPClient::HTTPClient() {
   assert(Curl && "Curl could not be initialized");
   // Set the callback hooks.
   curl_easy_setopt(Curl, CURLOPT_WRITEFUNCTION, curlWriteFunction);
+  // Detect supported compressed encodings and accept all.
+  curl_easy_setopt(Curl, CURLOPT_ACCEPT_ENCODING, "");
 }
 
 HTTPClient::~HTTPClient() { curl_easy_cleanup(Curl); }
diff --git a/llvm/test/tools/llvm-debuginfod-find/headers.test b/llvm/test/tools/llvm-debuginfod-find/headers.test
index c838d9fe7dc62de..86517f8fc5a1218 100644
--- a/llvm/test/tools/llvm-debuginfod-find/headers.test
+++ b/llvm/test/tools/llvm-debuginfod-find/headers.test
@@ -16,9 +16,11 @@ RUN: env DEBUGINFOD_CACHE=%t/debuginfod-cache DEBUGINFOD_HEADERS_FILE=%S/Inputs/
 RUN:   | FileCheck --check-prefix ERR -DHEADER_FILE=%S/Inputs/headers %s
 
 NO-HEADERS: Accept: */*
+NO-HEADERS-NEXT: Accept-Encoding: {{.*}}
 NO-HEADERS-NOT: {{.}}
 
 HEADERS:      Accept: */*
+HEADERS-NEXT: Accept-Encoding: {{.*}}
 HEADERS-NEXT: A: B
 HEADERS-NEXT: C: D
 HEADERS-NEXT: E: F



More information about the llvm-commits mailing list