Skip to content

Commit

Permalink
Don't decompress gzip data in http_client::download()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vslavik committed Oct 26, 2023
1 parent 8f82bc8 commit e58c8d1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/http_client_casablanca.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<http::http_response>
{
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"))
{
Expand Down

0 comments on commit e58c8d1

Please sign in to comment.