From 9308feabc045a3afd7eeb304a2324d17d03246df Mon Sep 17 00:00:00 2001 From: t Date: Sat, 13 Jun 2026 11:52:00 -0600 Subject: auth: thread provider extra_headers into request headers (C6) Add provider.mergeHeaders and use it in both the openai_chat and anthropic_messages providers so config extra_headers ride on the model request, merged onto the built-in header set. --- libpanto/src/provider_openai_chat.zig | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'libpanto/src/provider_openai_chat.zig') diff --git a/libpanto/src/provider_openai_chat.zig b/libpanto/src/provider_openai_chat.zig index 5713b5d..b236a60 100644 --- a/libpanto/src/provider_openai_chat.zig +++ b/libpanto/src/provider_openai_chat.zig @@ -103,18 +103,27 @@ pub const OpenAIChatRequest = struct { ); defer self.allocator.free(auth_value); - const extra_headers = [_]http.Header{ + const base_headers = [_]http.Header{ .{ .name = "content-type", .value = "application/json" }, .{ .name = "accept", .value = "text/event-stream" }, .{ .name = "authorization", .value = auth_value }, }; + // Merge provider `extra_headers` (e.g. Copilot editor identity, or + // auth-exchange-derived headers) onto the base set. Freed at the end + // of `open` — after the request body has been flushed. + const extra_headers = try provider_mod.mergeHeaders( + self.allocator, + &base_headers, + self.config.extra_headers, + ); + defer self.allocator.free(extra_headers); // Open the request. We can't use `fetch()` because it buffers the // response; we want to stream the body as it arrives. The request // is moved into the heap struct so the body reader (which borrows // `&rr.response`) stays valid across `produce` calls. rr.req = try self.http_client.request(.POST, uri, .{ - .extra_headers = &extra_headers, + .extra_headers = extra_headers, // Disable compression: gzip buffers small SSE frames, defeating // the streaming property we paid for `stream: true` to get. .headers = .{ .accept_encoding = .{ .override = "identity" } }, -- cgit v1.3