authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-16 00:24:58-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-23 02:37:11-07:00
logb6ca89fa7c0c4c766229586f1977babfb20d782a
tree8cec6a21c9e4625e06c07be230e5f0b14e7b1302
parent4d401e6159be774537bfcf8b57db7db1b44979e1

std.http.Client: disable zstd for now

The Allocator requirement is problematic.

1 files changed, 14 insertions(+), 21 deletions(-)

lib/std/http/Client.zig+14-21
...@@ -407,11 +407,13 @@ pub const RequestTransfer = union(enum) {...@@ -407,11 +407,13 @@ pub const RequestTransfer = union(enum) {
407pub const Compression = union(enum) {407pub const Compression = union(enum) {
408 pub const DeflateDecompressor = std.compress.zlib.Decompressor(Request.TransferReader);408 pub const DeflateDecompressor = std.compress.zlib.Decompressor(Request.TransferReader);
409 pub const GzipDecompressor = std.compress.gzip.Decompressor(Request.TransferReader);409 pub const GzipDecompressor = std.compress.gzip.Decompressor(Request.TransferReader);
410 pub const ZstdDecompressor = std.compress.zstd.DecompressStream(Request.TransferReader, .{});410 // https://github.com/ziglang/zig/issues/18937
411 //pub const ZstdDecompressor = std.compress.zstd.DecompressStream(Request.TransferReader, .{});
411412
412 deflate: DeflateDecompressor,413 deflate: DeflateDecompressor,
413 gzip: GzipDecompressor,414 gzip: GzipDecompressor,
414 zstd: ZstdDecompressor,415 // https://github.com/ziglang/zig/issues/18937
416 //zstd: ZstdDecompressor,
415 none: void,417 none: void,
416};418};
417419
...@@ -641,13 +643,6 @@ pub const Request = struct {...@@ -641,13 +643,6 @@ pub const Request = struct {
641643
642 /// Frees all resources associated with the request.644 /// Frees all resources associated with the request.
643 pub fn deinit(req: *Request) void {645 pub fn deinit(req: *Request) void {
644 switch (req.response.compression) {
645 .none => {},
646 .deflate => {},
647 .gzip => {},
648 .zstd => |*zstd| zstd.deinit(),
649 }
650
651 if (req.connection) |connection| {646 if (req.connection) |connection| {
652 if (req.response.parser.state != .complete) {647 if (req.response.parser.state != .complete) {
653 // If the response wasn't fully read, then we need to close the connection.648 // If the response wasn't fully read, then we need to close the connection.
...@@ -666,13 +661,6 @@ pub const Request = struct {...@@ -666,13 +661,6 @@ pub const Request = struct {
666 fn redirect(req: *Request, uri: Uri) !void {661 fn redirect(req: *Request, uri: Uri) !void {
667 assert(req.response.parser.state == .complete);662 assert(req.response.parser.state == .complete);
668663
669 switch (req.response.compression) {
670 .none => {},
671 .deflate => {},
672 .gzip => {},
673 .zstd => |*zstd| zstd.deinit(),
674 }
675
676 req.client.connection_pool.release(req.client.allocator, req.connection.?);664 req.client.connection_pool.release(req.client.allocator, req.connection.?);
677 req.connection = null;665 req.connection = null;
678666
...@@ -764,7 +752,9 @@ pub const Request = struct {...@@ -764,7 +752,9 @@ pub const Request = struct {
764 }752 }
765753
766 if (try emitOverridableHeader("accept-encoding: ", req.headers.accept_encoding, w)) {754 if (try emitOverridableHeader("accept-encoding: ", req.headers.accept_encoding, w)) {
767 try w.writeAll("accept-encoding: gzip, deflate, zstd\r\n");755 // https://github.com/ziglang/zig/issues/18937
756 //try w.writeAll("accept-encoding: gzip, deflate, zstd\r\n");
757 try w.writeAll("accept-encoding: gzip, deflate\r\n");
768 }758 }
769759
770 switch (req.transfer_encoding) {760 switch (req.transfer_encoding) {
...@@ -988,9 +978,11 @@ pub const Request = struct {...@@ -988,9 +978,11 @@ pub const Request = struct {
988 .gzip, .@"x-gzip" => req.response.compression = .{978 .gzip, .@"x-gzip" => req.response.compression = .{
989 .gzip = std.compress.gzip.decompressor(req.transferReader()),979 .gzip = std.compress.gzip.decompressor(req.transferReader()),
990 },980 },
991 .zstd => req.response.compression = .{981 // https://github.com/ziglang/zig/issues/18937
992 .zstd = std.compress.zstd.decompressStream(req.client.allocator, req.transferReader()),982 //.zstd => req.response.compression = .{
993 },983 // .zstd = std.compress.zstd.decompressStream(req.client.allocator, req.transferReader()),
984 //},
985 .zstd => return error.CompressionUnsupported,
994 }986 }
995 }987 }
996988
...@@ -1013,7 +1005,8 @@ pub const Request = struct {...@@ -1013,7 +1005,8 @@ pub const Request = struct {
1013 const out_index = switch (req.response.compression) {1005 const out_index = switch (req.response.compression) {
1014 .deflate => |*deflate| deflate.read(buffer) catch return error.DecompressionFailure,1006 .deflate => |*deflate| deflate.read(buffer) catch return error.DecompressionFailure,
1015 .gzip => |*gzip| gzip.read(buffer) catch return error.DecompressionFailure,1007 .gzip => |*gzip| gzip.read(buffer) catch return error.DecompressionFailure,
1016 .zstd => |*zstd| zstd.read(buffer) catch return error.DecompressionFailure,1008 // https://github.com/ziglang/zig/issues/18937
1009 //.zstd => |*zstd| zstd.read(buffer) catch return error.DecompressionFailure,
1017 else => try req.transferRead(buffer),1010 else => try req.transferRead(buffer),
1018 };1011 };
10191012