Skip to content

Lightpanda: the headless browser designed for AI and automation

Enable CURLOPT_PIPEWAIT on every easy handle

Adrià Arrufatdb9779a6541d
diff --git a/src/network/http.zig b/src/network/http.zig
index 9106ee685..da4bba545 100644
--- a/src/network/http.zig
+++ b/src/network/http.zig
@@ -455,6 +455,9 @@ pub const Connection = struct {
try libcurl.curl_easy_setopt(self._easy, .timeout_ms, config.httpTimeout());
try libcurl.curl_easy_setopt(self._easy, .connect_timeout_ms, config.httpConnectTimeout());
+ // Otherwise requests issued before ALPN settles each open a socket.
+ try libcurl.curl_easy_setopt(self._easy, .pipewait, true);
+
// compression, don't remove this. CloudFront will send gzip content
// even if we don't support it, and then it won't be decompressed.
// empty string means: use whatever's available
diff --git a/src/sys/libcurl.zig b/src/sys/libcurl.zig
index a08c7bfd6..6aa86c921 100644
--- a/src/sys/libcurl.zig
+++ b/src/sys/libcurl.zig
@@ -224,6 +224,7 @@ const CurlOption = enum(c.CURLoption) {
read_data = c.CURLOPT_READDATA,
read_function = c.CURLOPT_READFUNCTION,
connect_only = c.CURLOPT_CONNECT_ONLY,
+ pipewait = c.CURLOPT_PIPEWAIT,
upload = c.CURLOPT_UPLOAD,
opensocket_function = c.CURLOPT_OPENSOCKETFUNCTION,
opensocket_data = c.CURLOPT_OPENSOCKETDATA,
@@ -607,6 +608,7 @@ pub fn curl_easy_setopt(easy: *Curl, comptime option: CurlOption, value: anytype
.post,
.upload,
.http_get,
+ .pipewait,
.ssl_verify_peer,
.proxy_ssl_verify_peer,
=> @as(c_long, @intFromBool(value)),