Skip to content

Commit 2319485

Browse files
committed
copy our Request headers into the HTTP client
1 parent 8446a60 commit 2319485

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/browser/fetch/fetch.zig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,20 @@ pub fn fetch(input: RequestInput, options: ?RequestInit, page: *Page) !Env.Promi
105105
};
106106

107107
var headers = try Http.Headers.init();
108+
109+
// Copy our headers into the HTTP headers.
110+
var header_iter = req.headers.headers.iterator();
111+
while (header_iter.next()) |entry| {
112+
// This is fine because curl/headers copies it internally.
113+
const combined = try std.fmt.allocPrintSentinel(
114+
page.call_arena,
115+
"{s}: {s}",
116+
.{ entry.key_ptr.*, entry.value_ptr.* },
117+
0,
118+
);
119+
try headers.add(combined.ptr);
120+
}
121+
108122
try page.requestCookie(.{}).headersForRequest(arena, req.url, &headers);
109123

110124
const fetch_ctx = try arena.create(FetchContext);

0 commit comments

Comments
 (0)