fix(go): fix Go client to normalize request header keys using Header.Set - #24766
Open
Wuchieh wants to merge 1 commit into
Open
fix(go): fix Go client to normalize request header keys using Header.Set#24766Wuchieh wants to merge 1 commit into
Wuchieh wants to merge 1 commit into
Conversation
- Use Set when writing headerParams to http.Header to automatically apply canonical key formatting. - Avoid inconsistent casing or duplicate header issues caused by direct map assignment.
Author
|
@lwj5 Please review it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use
http.Header.Setwhen writingheaderParamstohttp.Headerin the generated Go client.Previously, generated code directly assigned values to the underlying
http.Headermap:This bypasses the header name canonicalization provided by
http.Header.Setand may result in inconsistent header casing or duplicate logical headers.This change replaces direct map assignment with:
Changes
http.Header.Setwhen writingheaderParamstohttp.Header.Related Issue
Fixes #24765
PR checklist
Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md).
Run the following to [build the project](https://github.com/openapitools/openapi-generator#14---build-projects) and update samples:
If your PR is targeting a particular programming language, @mention the relevant [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) members.
Summary by cubic
Normalizes request header keys in generated Go clients by using
http.Header.Setinstead of direct map assignment. This ensures canonical casing and prevents duplicate logical headers.headers[h] = []string{v}wrote headers without canonicalizing names. New behavior:headers.Set(h, v)canonicalizes and de-duplicates.headerParamscontains case-variant duplicates, only one canonical header is sent; the winning value depends on map iteration order.modules/openapi-generator/src/main/resources/go/client.mustache.Written for commit 70b0c1e. Summary will update on new commits.