make server_header_buffer non-optional

This commit is contained in:
James Morgan 2024-10-17 09:50:31 +08:00
parent 72cd507f3f
commit 161e796d6f

View File

@ -1666,7 +1666,7 @@ pub fn open(
} }
pub const FetchOptions = struct { pub const FetchOptions = struct {
server_header_buffer: ?[]u8 = null, server_header_buffer: []u8,
redirect_behavior: ?Request.RedirectBehavior = null, redirect_behavior: ?Request.RedirectBehavior = null,
/// If the server sends a body, it will be appended to this ArrayList. /// If the server sends a body, it will be appended to this ArrayList.
@ -1712,13 +1712,11 @@ pub fn fetch(client: *Client, options: FetchOptions) !Response {
.url => |u| try Uri.parse(u), .url => |u| try Uri.parse(u),
.uri => |u| u, .uri => |u| u,
}; };
var server_header_buffer: [16 * 1024]u8 = undefined;
const method: http.Method = options.method orelse const method: http.Method = options.method orelse
if (options.payload != null) .POST else .GET; if (options.payload != null) .POST else .GET;
var req = try open(client, method, uri, .{ var req = try open(client, method, uri, .{
.server_header_buffer = options.server_header_buffer orelse &server_header_buffer, .server_header_buffer = options.server_header_buffer,
.redirect_behavior = options.redirect_behavior orelse .redirect_behavior = options.redirect_behavior orelse
if (options.payload == null) @enumFromInt(3) else .unhandled, if (options.payload == null) @enumFromInt(3) else .unhandled,
.headers = options.headers, .headers = options.headers,