From cd28c3ca83aa33d43f29b71990eff6399ffe5f06 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 3 Apr 2022 22:22:22 -0700 Subject: [PATCH] Omit the `Content-Encoding` header when it was auto decompressed --- src/http_client_async.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/http_client_async.zig b/src/http_client_async.zig index fae3bde319..5210fe39f1 100644 --- a/src/http_client_async.zig +++ b/src/http_client_async.zig @@ -1018,6 +1018,12 @@ pub fn processResponse(this: *HTTPClient, comptime report_progress: bool, compti if (extremely_verbose) this.gzip_elapsed = gzip_timer.read(); + // if it compressed with this header, it is no longer + if (content_encoding_i < response.headers.len) { + var mutable_headers = std.ArrayListUnmanaged(picohttp.Header){ .items = response.headers, .capacity = response.headers.len }; + _ = mutable_headers.swapRemove(content_encoding_i); + response.headers = mutable_headers.items; + } }, else => {}, } @@ -1108,6 +1114,12 @@ pub fn processResponse(this: *HTTPClient, comptime report_progress: bool, compti if (extremely_verbose) this.gzip_elapsed = gzip_timer.read(); + // if it compressed with this header, it is no longer + if (content_encoding_i < response.headers.len) { + var mutable_headers = std.ArrayListUnmanaged(picohttp.Header){ .items = response.headers, .capacity = response.headers.len }; + _ = mutable_headers.swapRemove(content_encoding_i); + response.headers = mutable_headers.items; + } }, else => {}, }