authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-03-26 20:06:11-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-03-27 08:42:02+01:00
log0d25302d43557d89b868b8925b2e98395d1ebe60
treefdac48106d75cae799a834183e3471e48acd1ee6
parenta85495ca22e5410df00a59fe82fe480645ca3f85

Package.Fetch: bump redirect buffer size

RFC 9110 says > It is RECOMMENDED that all senders and recipients support, at a minimum, > URIs with lengths of 8000 octets in protocol elements. closes #30207

2 files changed, 4 insertions(+), 3 deletions(-)

lib/std/http/Client.zig+3-2
...@@ -1126,7 +1126,7 @@ pub const Request = struct {...@@ -1126,7 +1126,7 @@ pub const Request = struct {
1126 /// `redirect_buffer` must outlive accesses to `Request.uri`. If this1126 /// `redirect_buffer` must outlive accesses to `Request.uri`. If this
1127 /// buffer capacity would be exceeded, `error.HttpRedirectLocationOversize`1127 /// buffer capacity would be exceeded, `error.HttpRedirectLocationOversize`
1128 /// is returned instead. This buffer may be empty if no redirects are to be1128 /// is returned instead. This buffer may be empty if no redirects are to be
1129 /// handled.1129 /// handled. RFC 9110 recommends making this at least 8000 bytes.
1130 ///1130 ///
1131 /// If this fails with `error.ReadFailed` then the `Connection.getReadError`1131 /// If this fails with `error.ReadFailed` then the `Connection.getReadError`
1132 /// method of `r.connection` can be used to get more detailed information.1132 /// method of `r.connection` can be used to get more detailed information.
...@@ -1748,7 +1748,8 @@ pub fn request(...@@ -1748,7 +1748,8 @@ pub fn request(
1748}1748}
17491749
1750pub const FetchOptions = struct {1750pub const FetchOptions = struct {
1751 /// `null` means it will be heap-allocated.1751 /// `null` means it will be heap-allocated. RFC 9110 recommends at least
1752 /// 8000 bytes.
1752 redirect_buffer: ?[]u8 = null,1753 redirect_buffer: ?[]u8 = null,
1753 /// `null` means it will be heap-allocated.1754 /// `null` means it will be heap-allocated.
1754 decompress_buffer: ?[]u8 = null,1755 decompress_buffer: ?[]u8 = null,
src/Package/Fetch.zig+1-1
...@@ -1193,7 +1193,7 @@ fn initResource(f: *Fetch, uri: std.Uri, resource: *Resource, reader_buffer: []u...@@ -1193,7 +1193,7 @@ fn initResource(f: *Fetch, uri: std.Uri, resource: *Resource, reader_buffer: []u
1193 request.sendBodiless() catch |err|1193 request.sendBodiless() catch |err|
1194 return f.fail(f.location_tok, try eb.printString("HTTP request failed: {t}", .{err}));1194 return f.fail(f.location_tok, try eb.printString("HTTP request failed: {t}", .{err}));
11951195
1196 var redirect_buffer: [1024]u8 = undefined;1196 var redirect_buffer: [8000]u8 = undefined;
1197 const response = &resource.http_request.response;1197 const response = &resource.http_request.response;
1198 response.* = request.receiveHead(&redirect_buffer) catch |err| switch (err) {1198 response.* = request.receiveHead(&redirect_buffer) catch |err| switch (err) {
1199 error.ReadFailed => {1199 error.ReadFailed => {