diff options
| author | t <t@tjp.lol> | 2026-06-13 11:52:00 -0600 |
|---|---|---|
| committer | t <t@tjp.lol> | 2026-06-15 15:08:32 -0600 |
| commit | 9308feabc045a3afd7eeb304a2324d17d03246df (patch) | |
| tree | c3efa7b54268af94deb0fd00d99a5d53d1f86ac9 /libpanto/src/provider_openai_chat.zig | |
| parent | deb4ce4a1a76869771bfcdd758455c49815f0d13 (diff) | |
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.
Diffstat (limited to 'libpanto/src/provider_openai_chat.zig')
| -rw-r--r-- | libpanto/src/provider_openai_chat.zig | 13 |
1 files changed, 11 insertions, 2 deletions
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" } }, |
