authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-08-06 19:01:22-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-08-07 10:04:52-07:00
log6b411f147c49ce0a0004f314b9c40e78ed804c5b
treea8fdedcb447672b24be4120be41220a0398157f0
parent618a435ad4ea259d2e2546ad4b85e2e01f087493

std.http: address review comments

thank you everybody

3 files changed, 6 insertions(+), 9 deletions(-)

lib/std/Uri.zig+2-1
...@@ -377,7 +377,8 @@ pub fn parse(text: []const u8) ParseError!Uri {...@@ -377,7 +377,8 @@ pub fn parse(text: []const u8) ParseError!Uri {
377377
378pub const ResolveInPlaceError = ParseError || error{NoSpaceLeft};378pub const ResolveInPlaceError = ParseError || error{NoSpaceLeft};
379379
380/// Resolves a URI against a base URI, conforming to RFC 3986, Section 5.380/// Resolves a URI against a base URI, conforming to
381/// [RFC 3986, Section 5](https://www.rfc-editor.org/rfc/rfc3986#section-5)
381///382///
382/// Assumes new location is already copied to the beginning of `aux_buf.*`.383/// Assumes new location is already copied to the beginning of `aux_buf.*`.
383/// Parses that new location as a URI, and then resolves the path in place.384/// Parses that new location as a URI, and then resolves the path in place.
lib/std/http.zig+2-2
...@@ -496,7 +496,7 @@ pub const Reader = struct {...@@ -496,7 +496,7 @@ pub const Reader = struct {
496 return reader.in;496 return reader.in;
497 },497 },
498 .deflate => {498 .deflate => {
499 decompressor.* = .{ .flate = .init(reader.in, .raw, decompression_buffer) };499 decompressor.* = .{ .flate = .init(reader.in, .zlib, decompression_buffer) };
500 return &decompressor.flate.reader;500 return &decompressor.flate.reader;
501 },501 },
502 .gzip => {502 .gzip => {
...@@ -730,7 +730,7 @@ pub const Decompressor = union(enum) {...@@ -730,7 +730,7 @@ pub const Decompressor = union(enum) {
730 return transfer_reader;730 return transfer_reader;
731 },731 },
732 .deflate => {732 .deflate => {
733 decompressor.* = .{ .flate = .init(transfer_reader, .raw, buffer) };733 decompressor.* = .{ .flate = .init(transfer_reader, .zlib, buffer) };
734 return &decompressor.flate.reader;734 return &decompressor.flate.reader;
735 },735 },
736 .gzip => {736 .gzip => {
lib/std/http/Client.zig+2-6
...@@ -115,8 +115,6 @@ pub const ConnectionPool = struct {...@@ -115,8 +115,6 @@ pub const ConnectionPool = struct {
115 /// Tries to release a connection back to the connection pool.115 /// Tries to release a connection back to the connection pool.
116 /// If the connection is marked as closing, it will be closed instead.116 /// If the connection is marked as closing, it will be closed instead.
117 ///117 ///
118 /// `allocator` must be the same one used to create `connection`.
119 ///
120 /// Threadsafe.118 /// Threadsafe.
121 pub fn release(pool: *ConnectionPool, connection: *Connection) void {119 pub fn release(pool: *ConnectionPool, connection: *Connection) void {
122 pool.mutex.lock();120 pool.mutex.lock();
...@@ -484,10 +482,8 @@ pub const Response = struct {...@@ -484,10 +482,8 @@ pub const Response = struct {
484 };482 };
485 var it = mem.splitSequence(u8, bytes, "\r\n");483 var it = mem.splitSequence(u8, bytes, "\r\n");
486484
487 const first_line = it.next().?;485 const first_line = it.first();
488 if (first_line.len < 12) {486 if (first_line.len < 12) return error.HttpHeadersInvalid;
489 return error.HttpHeadersInvalid;
490 }
491487
492 const version: http.Version = switch (int64(first_line[0..8])) {488 const version: http.Version = switch (int64(first_line[0..8])) {
493 int64("HTTP/1.0") => .@"HTTP/1.0",489 int64("HTTP/1.0") => .@"HTTP/1.0",