From e58c8d1568287dd05ea1e390178685bb405f9eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Thu, 26 Oct 2023 12:58:01 +0200 Subject: [PATCH] Don't decompress gzip data in http_client::download() When using C++REST SDK, don't transparently decompressed gzip-compressed content if it is application/octet-stream. Only do that for other content types, typically JSON. macOS implementation already behaves this way natively. --- src/http_client_casablanca.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/http_client_casablanca.cpp b/src/http_client_casablanca.cpp index 30e31354e0..ddd4f01f70 100644 --- a/src/http_client_casablanca.cpp +++ b/src/http_client_casablanca.cpp @@ -89,6 +89,9 @@ class gzip_compression_support : public http::http_pipeline_stage return next_stage()->propagate(request).then([](http::http_response response) -> pplx::task { + if (response.headers().content_type() == _XPLATSTR("application/octet-stream")) + return pplx::task_from_result(response); // don't try to decompress binary data + string_t encoding; if (response.headers().match(http::header_names::content_encoding, encoding) && encoding == _XPLATSTR("gzip")) {