std.http: address review comments

thank you everybody
This commit is contained in:
Andrew Kelley 2025-08-06 19:01:22 -07:00
parent 618a435ad4
commit 6b411f147c
3 changed files with 6 additions and 9 deletions

View file

@ -377,7 +377,8 @@ pub fn parse(text: []const u8) ParseError!Uri {
pub const ResolveInPlaceError = ParseError || error{NoSpaceLeft}; pub const ResolveInPlaceError = ParseError || error{NoSpaceLeft};
/// Resolves a URI against a base URI, conforming to RFC 3986, Section 5. /// Resolves a URI against a base URI, conforming to
/// [RFC 3986, Section 5](https://www.rfc-editor.org/rfc/rfc3986#section-5)
/// ///
/// Assumes new location is already copied to the beginning of `aux_buf.*`. /// Assumes new location is already copied to the beginning of `aux_buf.*`.
/// Parses that new location as a URI, and then resolves the path in place. /// Parses that new location as a URI, and then resolves the path in place.

View file

@ -496,7 +496,7 @@ pub const Reader = struct {
return reader.in; return reader.in;
}, },
.deflate => { .deflate => {
decompressor.* = .{ .flate = .init(reader.in, .raw, decompression_buffer) }; decompressor.* = .{ .flate = .init(reader.in, .zlib, decompression_buffer) };
return &decompressor.flate.reader; return &decompressor.flate.reader;
}, },
.gzip => { .gzip => {
@ -730,7 +730,7 @@ pub const Decompressor = union(enum) {
return transfer_reader; return transfer_reader;
}, },
.deflate => { .deflate => {
decompressor.* = .{ .flate = .init(transfer_reader, .raw, buffer) }; decompressor.* = .{ .flate = .init(transfer_reader, .zlib, buffer) };
return &decompressor.flate.reader; return &decompressor.flate.reader;
}, },
.gzip => { .gzip => {

View file

@ -115,8 +115,6 @@ pub const ConnectionPool = struct {
/// Tries to release a connection back to the connection pool. /// Tries to release a connection back to the connection pool.
/// If the connection is marked as closing, it will be closed instead. /// If the connection is marked as closing, it will be closed instead.
/// ///
/// `allocator` must be the same one used to create `connection`.
///
/// Threadsafe. /// Threadsafe.
pub fn release(pool: *ConnectionPool, connection: *Connection) void { pub fn release(pool: *ConnectionPool, connection: *Connection) void {
pool.mutex.lock(); pool.mutex.lock();
@ -484,10 +482,8 @@ pub const Response = struct {
}; };
var it = mem.splitSequence(u8, bytes, "\r\n"); var it = mem.splitSequence(u8, bytes, "\r\n");
const first_line = it.next().?; const first_line = it.first();
if (first_line.len < 12) { if (first_line.len < 12) return error.HttpHeadersInvalid;
return error.HttpHeadersInvalid;
}
const version: http.Version = switch (int64(first_line[0..8])) { const version: http.Version = switch (int64(first_line[0..8])) {
int64("HTTP/1.0") => .@"HTTP/1.0", int64("HTTP/1.0") => .@"HTTP/1.0",