summaryrefslogtreecommitdiff
path: root/libpanto/src/provider_openai_chat.zig
diff options
context:
space:
mode:
Diffstat (limited to 'libpanto/src/provider_openai_chat.zig')
-rw-r--r--libpanto/src/provider_openai_chat.zig13
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" } },