Lightpanda: the headless browser designed for AI and automation
use curl no body option for head requests
Muki Kiboigo00c98313c243
diff --git a/src/network/HttpClient.zig b/src/network/HttpClient.zigindex 79f3e1238..a608f9ca8 100644--- a/src/network/HttpClient.zig+++ b/src/network/HttpClient.zig@@ -3208,6 +3208,8 @@ pub const Transfer = struct {try conn.setMethod(req.method);if (req.body) |b| {try conn.setBody(b);+ } else if (req.method == .HEAD) {+ try conn.setNoBody();} else {try conn.setGetMode();}diff --git a/src/network/http.zig b/src/network/http.zigindex da4bba545..decb1e8e9 100644--- a/src/network/http.zig+++ b/src/network/http.zig@@ -348,6 +348,11 @@ pub const Connection = struct {try libcurl.curl_easy_setopt(easy, .copy_post_fields, body.ptr);}+ pub fn setNoBody(self: *const Connection) !void {+ const easy = self._easy;+ try libcurl.curl_easy_setopt(easy, .no_body, true);+ }+pub fn setGetMode(self: *const Connection) !void {try libcurl.curl_easy_setopt(self._easy, .http_get, true);}diff --git a/src/sys/libcurl.zig b/src/sys/libcurl.zigindex 6aa86c921..030ad4666 100644--- a/src/sys/libcurl.zig+++ b/src/sys/libcurl.zig@@ -212,6 +212,7 @@ const CurlOption = enum(c.CURLoption) {post_field_size = c.CURLOPT_POSTFIELDSIZE,copy_post_fields = c.CURLOPT_COPYPOSTFIELDS,http_get = c.CURLOPT_HTTPGET,+ no_body = c.CURLOPT_NOBODY,http_header = c.CURLOPT_HTTPHEADER,cookie = c.CURLOPT_COOKIE,private = c.CURLOPT_PRIVATE,@@ -609,6 +610,7 @@ pub fn curl_easy_setopt(easy: *Curl, comptime option: CurlOption, value: anytype.upload,.http_get,.pipewait,+ .no_body,.ssl_verify_peer,.proxy_ssl_verify_peer,=> @as(c_long, @intFromBool(value)),