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.
This commit is contained in:
Chris Burgess 2023-09-26 17:16:40 -04:00 committed by GitHub
parent 5d907171e2
commit 1c726bcb32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 0 deletions

View File

@ -285,6 +285,7 @@ pub const TransferEncoding = enum {
};
pub const ContentEncoding = enum {
identity,
compress,
deflate,
gzip,

View File

@ -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,

View File

@ -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,