From 1c726bcb321d03ac74d1bd646b690991ba356fd8 Mon Sep 17 00:00:00 2001 From: Chris Burgess <9002722+cgbur@users.noreply.github.com> Date: Tue, 26 Sep 2023 17:16:40 -0400 Subject: [PATCH] std.http: add identity to content encodings (#16493) Some servers will respond with the identity encoding, meaning no encoding, especially when responding to range-get requests. Adding the identity encoding stops the header parser from failing when it encounters this. --- lib/std/http.zig | 1 + lib/std/http/Client.zig | 1 + lib/std/http/Server.zig | 1 + 3 files changed, 3 insertions(+) diff --git a/lib/std/http.zig b/lib/std/http.zig index 424cbc8bb7..12dc4b89cd 100644 --- a/lib/std/http.zig +++ b/lib/std/http.zig @@ -285,6 +285,7 @@ pub const TransferEncoding = enum { }; pub const ContentEncoding = enum { + identity, compress, deflate, gzip, diff --git a/lib/std/http/Client.zig b/lib/std/http/Client.zig index ed7c24e931..bfb96f2cfc 100644 --- a/lib/std/http/Client.zig +++ b/lib/std/http/Client.zig @@ -762,6 +762,7 @@ pub const Request = struct { req.response.skip = false; if (!req.response.parser.done) { if (req.response.transfer_compression) |tc| switch (tc) { + .identity => req.response.compression = .none, .compress => return error.CompressionNotSupported, .deflate => req.response.compression = .{ .deflate = std.compress.zlib.decompressStream(req.client.allocator, req.transferReader()) catch return error.CompressionInitializationFailed, diff --git a/lib/std/http/Server.zig b/lib/std/http/Server.zig index c493cc1bab..04bdfe39b7 100644 --- a/lib/std/http/Server.zig +++ b/lib/std/http/Server.zig @@ -528,6 +528,7 @@ pub const Response = struct { if (!res.request.parser.done) { if (res.request.transfer_compression) |tc| switch (tc) { + .identity => res.request.compression = .none, .compress => return error.CompressionNotSupported, .deflate => res.request.compression = .{ .deflate = std.compress.zlib.decompressStream(res.allocator, res.transferReader()) catch return error.CompressionInitializationFailed,