Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(gensupport): merge x-goog-api-client vals into a single header #2612

Merged
merged 5 commits into from
Jun 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
flip conditional
  • Loading branch information
BrennaEpp committed Jun 7, 2024
commit 649a71fa9c6f1459af806a837e5c331c482a9b5d
10 changes: 5 additions & 5 deletions internal/gensupport/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ func SendRequest(ctx context.Context, client *http.Client, req *http.Request) (*
if ctx != nil {
headers := callctx.HeadersFromContext(ctx)
for k, vals := range headers {
if k != "x-goog-api-client" {
for _, v := range vals {
req.Header.Add(k, v)
}
} else {
if k == "x-goog-api-client" {
// Merge all values into a single "x-goog-api-client" header.
var mergedVal strings.Builder
baseXGoogHeader := req.Header.Get("X-Goog-Api-Client")
Expand All @@ -66,6 +62,10 @@ func SendRequest(ctx context.Context, client *http.Client, req *http.Request) (*
}
// Remove the last space and replace the header on the request.
req.Header.Set(k, mergedVal.String()[:mergedVal.Len()-1])
} else {
for _, v := range vals {
req.Header.Add(k, v)
}
}
}
}
Expand Down