@@ -121,7 +121,8 @@ fn setExtraHTTPHeaders(cmd: anytype) !void {
121121 try extra_headers .ensureTotalCapacity (arena , params .headers .map .count ());
122122 var it = params .headers .map .iterator ();
123123 while (it .next ()) | header | {
124- extra_headers .appendAssumeCapacity (.{ .name = try arena .dupe (u8 , header .key_ptr .* ), .value = try arena .dupe (u8 , header .value_ptr .* ) });
124+ const header_string = try std .fmt .allocPrintZ (arena , "{s}: {s}" , .{ header .key_ptr .* , header .value_ptr .* });
125+ extra_headers .appendAssumeCapacity (header_string );
125126 }
126127
127128 return cmd .sendResult (null , .{});
@@ -233,19 +234,6 @@ fn getCookies(cmd: anytype) !void {
233234 try cmd .sendResult (.{ .cookies = writer }, .{});
234235}
235236
236- // Upsert a header into the headers array.
237- // returns true if the header was added, false if it was updated
238- fn putAssumeCapacity (headers : * std .ArrayListUnmanaged (std.http.Header ), extra : std .http .Header ) bool {
239- for (headers .items ) | * header | {
240- if (std .mem .eql (u8 , header .name , extra .name )) {
241- header .value = extra .value ;
242- return false ;
243- }
244- }
245- headers .appendAssumeCapacity (extra );
246- return true ;
247- }
248-
249237pub fn httpRequestFail (arena : Allocator , bc : anytype , data : * const Notification.RequestFail ) ! void {
250238 // It's possible that the request failed because we aborted when the client
251239 // sent Target.closeTarget. In that case, bc.session_id will be cleared
@@ -279,12 +267,9 @@ pub fn httpRequestStart(arena: Allocator, bc: anytype, data: *const Notification
279267 const page = bc .session .currentPage () orelse unreachable ;
280268
281269 // Modify request with extra CDP headers
282- // @newhttp
283- // try request.headers.ensureTotalCapacity(request.arena, request.headers.items.len + cdp.extra_headers.items.len);
284- // for (cdp.extra_headers.items) |extra| {
285- // const new = putAssumeCapacity(request.headers, extra);
286- // if (!new) log.debug(.cdp, "request header overwritten", .{ .name = extra.name });
287- // }
270+ for (cdp .extra_headers .items ) | extra | {
271+ try data .transfer .req .headers .add (extra );
272+ }
288273
289274 const document_url = try urlToString (arena , & page .url .uri , .{
290275 .scheme = true ,
0 commit comments