Jan Kundrát | 8cd0e25 | 2019-12-05 17:49:48 +0100 | [diff] [blame] | 1 | From 256274e4ca5786b4e68011fcb1b31272e278141d Mon Sep 17 00:00:00 2001 |
| 2 | From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= <jan.kundrat@cesnet.cz> |
| 3 | Date: Thu, 5 Dec 2019 17:03:06 +0100 |
| 4 | Subject: [PATCH] curl: Enable decoding from server's Content-Encoding |
| 5 | |
| 6 | I would like to consume RAUC bundles straight from our CI environment |
| 7 | which uses OpenStack Swift as a backend for artifact storage, and |
| 8 | OpenDev's Zuul as the CI runner. As it happens, our CI jobs sends file |
| 9 | content to Swift with a Content-Encoding: gzip [1], and Swift appears to |
| 10 | always send the file with that Content-Encoding no matter what |
| 11 | Accept-Encoding the HTTP client sends in their request. |
| 12 | |
| 13 | This patch simply uses curl's list of default supported Content-Encoding |
| 14 | decoders (that's the special magic "" value of this header). The end |
| 15 | result is that our boxes can now fetch stuff from our CI environment |
| 16 | without any problems. |
| 17 | |
| 18 | [1] https://review.opendev.org/688154 |
| 19 | --- |
| 20 | src/network.c | 1 + |
| 21 | 1 file changed, 1 insertion(+) |
| 22 | |
| 23 | diff --git a/src/network.c b/src/network.c |
| 24 | index ade9f21..5793093 100644 |
| 25 | --- a/src/network.c |
| 26 | +++ b/src/network.c |
| 27 | @@ -93,6 +93,7 @@ static gboolean transfer(RaucTransfer *xfer, GError **error) |
| 28 | curl_easy_setopt(curl, CURLOPT_XFERINFODATA, xfer); |
| 29 | curl_easy_setopt(curl, CURLOPT_FAILONERROR, xfer); |
| 30 | curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf); |
| 31 | + curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, ""); /* decode all supported Accept-Encoding headers */ |
| 32 | |
| 33 | /* set error buffer empty before perorming a request */ |
| 34 | errbuf[0] = 0; |
| 35 | -- |
| 36 | 2.21.0 |
| 37 | |