copy our Request headers into the HTTP client

This commit is contained in:
Muki Kiboigo
2025-09-11 21:19:03 -07:00
parent 0423a178e9
commit 37d8d2642d

View File

@@ -105,6 +105,20 @@ pub fn fetch(input: RequestInput, options: ?RequestInit, page: *Page) !Env.Promi
};
var headers = try Http.Headers.init();
// Copy our headers into the HTTP headers.
var header_iter = req.headers.headers.iterator();
while (header_iter.next()) |entry| {
// This is fine because curl/headers copies it internally.
const combined = try std.fmt.allocPrintSentinel(
page.call_arena,
"{s}: {s}",
.{ entry.key_ptr.*, entry.value_ptr.* },
0,
);
try headers.add(combined.ptr);
}
try page.requestCookie(.{}).headersForRequest(arena, req.url, &headers);
const fetch_ctx = try arena.create(FetchContext);