MCPcopy Create free account
hub / github.com/coder/aibridge / BuildUpstreamHeaders

Function BuildUpstreamHeaders

intercept/client_headers.go:58–74  ·  view source on GitHub ↗

BuildUpstreamHeaders produces the header set for an upstream SDK request. It starts from the prepared client headers, then preserves specific headers from the SDK-built request that must not be overwritten.

(sdkHeader http.Header, clientHeaders http.Header, authHeaderName string)

Source from the content-addressed store, hash-verified

56// It starts from the prepared client headers, then preserves specific
57// headers from the SDK-built request that must not be overwritten.
58func BuildUpstreamHeaders(sdkHeader http.Header, clientHeaders http.Header, authHeaderName string) http.Header {
59 headers := PrepareClientHeaders(clientHeaders)
60
61 // Preserve the auth header set by the SDK from the provider configuration.
62 if v := sdkHeader.Get(authHeaderName); v != "" {
63 headers.Set(authHeaderName, v)
64 }
65
66 // Preserve actor headers injected by aibridge as per-request SDK options.
67 for name, values := range sdkHeader {
68 if IsActorHeader(name) {
69 headers[name] = values
70 }
71 }
72
73 return headers
74}

Callers 4

TestBuildUpstreamHeadersFunction · 0.92
newResponsesServiceMethod · 0.92
newMessagesServiceMethod · 0.92
newCompletionsServiceMethod · 0.92

Calls 3

PrepareClientHeadersFunction · 0.85
IsActorHeaderFunction · 0.85
GetMethod · 0.80

Tested by 1

TestBuildUpstreamHeadersFunction · 0.74