authorgravatar for 9002722+cgbur@users.noreply.github.comChris Burgess <9002722+cgbur@users.noreply.github.com> 2023-09-26 17:16:40-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-09-26 17:16:40-04:00
log1c726bcb321d03ac74d1bd646b690991ba356fd8
tree21acaa9feaa3d57a969a80263feaf0cc77492536
parent5d907171e2941be9ad62e289ceeb17e7b4c0be2b
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

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.

3 files changed, 3 insertions(+), 0 deletions(-)

lib/std/http.zig+1
...@@ -285,6 +285,7 @@ pub const TransferEncoding = enum {...@@ -285,6 +285,7 @@ pub const TransferEncoding = enum {
285};285};
286286
287pub const ContentEncoding = enum {287pub const ContentEncoding = enum {
288 identity,
288 compress,289 compress,
289 deflate,290 deflate,
290 gzip,291 gzip,
lib/std/http/Client.zig+1
...@@ -762,6 +762,7 @@ pub const Request = struct {...@@ -762,6 +762,7 @@ pub const Request = struct {
762 req.response.skip = false;762 req.response.skip = false;
763 if (!req.response.parser.done) {763 if (!req.response.parser.done) {
764 if (req.response.transfer_compression) |tc| switch (tc) {764 if (req.response.transfer_compression) |tc| switch (tc) {
765 .identity => req.response.compression = .none,
765 .compress => return error.CompressionNotSupported,766 .compress => return error.CompressionNotSupported,
766 .deflate => req.response.compression = .{767 .deflate => req.response.compression = .{
767 .deflate = std.compress.zlib.decompressStream(req.client.allocator, req.transferReader()) catch return error.CompressionInitializationFailed,768 .deflate = std.compress.zlib.decompressStream(req.client.allocator, req.transferReader()) catch return error.CompressionInitializationFailed,
lib/std/http/Server.zig+1
...@@ -528,6 +528,7 @@ pub const Response = struct {...@@ -528,6 +528,7 @@ pub const Response = struct {
528528
529 if (!res.request.parser.done) {529 if (!res.request.parser.done) {
530 if (res.request.transfer_compression) |tc| switch (tc) {530 if (res.request.transfer_compression) |tc| switch (tc) {
531 .identity => res.request.compression = .none,
531 .compress => return error.CompressionNotSupported,532 .compress => return error.CompressionNotSupported,
532 .deflate => res.request.compression = .{533 .deflate => res.request.compression = .{
533 .deflate = std.compress.zlib.decompressStream(res.allocator, res.transferReader()) catch return error.CompressionInitializationFailed,534 .deflate = std.compress.zlib.decompressStream(res.allocator, res.transferReader()) catch return error.CompressionInitializationFailed,