mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-16 08:18:59 +00:00
Add command line options to control HTTP client
http_timeout_ms http_connect_timeout_ms http_max_host_open http_max_concurrent
This commit is contained in:
@@ -102,6 +102,8 @@ pub fn init(allocator: Allocator, ca_blob: ?c.curl_blob, opts: Http.Opts) !*Clie
|
||||
const multi = c.curl_multi_init() orelse return error.FailedToInitializeMulti;
|
||||
errdefer _ = c.curl_multi_cleanup(multi);
|
||||
|
||||
try errorMCheck(c.curl_multi_setopt(multi, c.CURLMOPT_MAX_HOST_CONNECTIONS, @as(c_long, opts.max_host_open)));
|
||||
|
||||
var handles = try Handles.init(allocator, client, ca_blob, &opts);
|
||||
errdefer handles.deinit(allocator);
|
||||
|
||||
@@ -346,8 +348,7 @@ const Handles = struct {
|
||||
|
||||
// pointer to opts is not stable, don't hold a reference to it!
|
||||
fn init(allocator: Allocator, client: *Client, ca_blob: ?c.curl_blob, opts: *const Http.Opts) !Handles {
|
||||
const count = opts.max_concurrent_transfers;
|
||||
std.debug.assert(count > 0);
|
||||
const count = if (opts.max_concurrent == 0) 1 else opts.max_concurrent;
|
||||
|
||||
const handles = try allocator.alloc(Handle, count);
|
||||
errdefer allocator.free(handles);
|
||||
|
||||
@@ -230,11 +230,12 @@ pub fn errorMCheck(code: c.CURLMcode) errors.Multi!void {
|
||||
}
|
||||
|
||||
pub const Opts = struct {
|
||||
timeout_ms: u31 = 0,
|
||||
timeout_ms: u31,
|
||||
max_host_open: u8,
|
||||
max_concurrent: u8,
|
||||
connect_timeout_ms: u31,
|
||||
max_redirects: u8 = 10,
|
||||
tls_verify_host: bool = true,
|
||||
connect_timeout_ms: u31 = 5000,
|
||||
max_concurrent_transfers: u8 = 5,
|
||||
http_proxy: ?[:0]const u8 = null,
|
||||
proxy_bearer_token: ?[:0]const u8 = null,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user