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) {
407407pub const Compression = union(enum) {
408408 pub const DeflateDecompressor = std.compress.zlib.Decompressor(Request.TransferReader);
409409 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
412413 deflate: DeflateDecompressor,
413414 gzip: GzipDecompressor,
414 zstd: ZstdDecompressor,
415 // https://github.com/ziglang/zig/issues/18937
416 //zstd: ZstdDecompressor,
415417 none: void,
416418};
417419
......@@ -641,13 +643,6 @@ pub const Request = struct {
641643
642644 /// Frees all resources associated with the request.
643645 pub fn deinit(req: *Request) void {
644 switch (req.response.compression) {
645 .none => {},
646 .deflate => {},
647 .gzip => {},
648 .zstd => |*zstd| zstd.deinit(),
649 }
650
651646 if (req.connection) |connection| {
652647 if (req.response.parser.state != .complete) {
653648 // If the response wasn't fully read, then we need to close the connection.
......@@ -666,13 +661,6 @@ pub const Request = struct {
666661 fn redirect(req: *Request, uri: Uri) !void {
667662 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
676664 req.client.connection_pool.release(req.client.allocator, req.connection.?);
677665 req.connection = null;
678666
......@@ -764,7 +752,9 @@ pub const Request = struct {
764752 }
765753
766754 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");
768758 }
769759
770760 switch (req.transfer_encoding) {
......@@ -988,9 +978,11 @@ pub const Request = struct {
988978 .gzip, .@"x-gzip" => req.response.compression = .{
989979 .gzip = std.compress.gzip.decompressor(req.transferReader()),
990980 },
991 .zstd => req.response.compression = .{
992 .zstd = std.compress.zstd.decompressStream(req.client.allocator, req.transferReader()),
993 },
981 // https://github.com/ziglang/zig/issues/18937
982 //.zstd => req.response.compression = .{
983 // .zstd = std.compress.zstd.decompressStream(req.client.allocator, req.transferReader()),
984 //},
985 .zstd => return error.CompressionUnsupported,
994986 }
995987 }
996988
......@@ -1013,7 +1005,8 @@ pub const Request = struct {
10131005 const out_index = switch (req.response.compression) {
10141006 .deflate => |*deflate| deflate.read(buffer) catch return error.DecompressionFailure,
10151007 .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,
10171010 else => try req.transferRead(buffer),
10181011 };
10191012