mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
http/Client: Allow passing a connection to fetch()
This allows developers to easily use fetch for unix sockets, instead of having to use the low-level http.Client API.
This commit is contained in:
parent
6bd1f508c9
commit
90fcac603a
1 changed files with 5 additions and 1 deletions
|
|
@ -1406,7 +1406,7 @@ pub fn connectUnix(client: *Client, path: []const u8) ConnectUnixError!*Connecti
|
|||
|
||||
const conn = try client.allocator.create(Connection);
|
||||
errdefer client.allocator.destroy(conn);
|
||||
|
||||
|
||||
const stream = try std.net.connectUnixSocket(path);
|
||||
errdefer stream.close();
|
||||
|
||||
|
|
@ -1707,6 +1707,9 @@ pub const FetchOptions = struct {
|
|||
raw_uri: bool = false,
|
||||
keep_alive: bool = true,
|
||||
|
||||
/// Must be an already acquired connection.
|
||||
connection: ?*Connection = null,
|
||||
|
||||
/// Standard headers that have default, but overridable, behavior.
|
||||
headers: Request.Headers = .{},
|
||||
/// These headers are kept including when following a redirect to a
|
||||
|
|
@ -1756,6 +1759,7 @@ pub fn fetch(client: *Client, options: FetchOptions) !FetchResult {
|
|||
.extra_headers = options.extra_headers,
|
||||
.privileged_headers = options.privileged_headers,
|
||||
.keep_alive = options.keep_alive,
|
||||
.connection = options.connection,
|
||||
});
|
||||
defer req.deinit();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue