commit 1c726bcb321d03ac74d1bd646b690991ba356fd8 (tree)
parent 5d907171e2941be9ad62e289ceeb17e7b4c0be2b
Author: Chris Burgess <9002722+cgbur@users.noreply.github.com>
Date: Tue, 26 Sep 2023 17:16:40 -0400
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.
Diffstat:
3 files changed, 3 insertions(+), 0 deletions(-)
diff --git 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
@@ -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
@@ -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,