Accurately reflect the canonical casing of API-Version and OS-Type headers#49054
Merged
thaJeztah merged 1 commit intomoby:masterfrom Dec 16, 2024
Merged
Accurately reflect the canonical casing of API-Version and OS-Type headers#49054thaJeztah merged 1 commit intomoby:masterfrom
API-Version and OS-Type headers#49054thaJeztah merged 1 commit intomoby:masterfrom
Conversation
f84d374 to
510b8b4
Compare
…` headers Go automatically canonicalises HTTP headers, meaning the string `API-Version` passed as a header has always been returned as `Api-Version`. Similarly, `OSType` is returned as `Ostype`. This commit updates the documentation to reflect this behaviour and modifies the codebase to ensure that input strings are aligned with their canonical output values. Signed-off-by: maggie44 <[email protected]>
API-Version and OS-Type headers
thaJeztah
reviewed
Dec 9, 2024
Comment on lines
-70
to
+71
| w.Header().Set("API-Version", v.defaultAPIVersion) | ||
| w.Header().Set("OSType", runtime.GOOS) | ||
| w.Header().Set("Api-Version", v.defaultAPIVersion) | ||
| w.Header().Set("Ostype", runtime.GOOS) |
Member
There was a problem hiding this comment.
For others reviewing; I suggested changing these to match the normalised version. Effectively these parts of the change are a "no-op", but explicitly setting the headers in the normalised form (instead of them implicitly being normalised by Go stdlib) reduces confusion.
As a follow-up to this PR I want to have a peek if we could define consts for this (on which we could document why they're capitalised as they are), but I have not yet looked at the impact of that (i.e.; where to best put the const without that resulting in cumbersome imports / inter-package dependencies).
This was referenced Dec 16, 2024
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.
Go automatically canonicalises HTTP headers, meaning the string
API-Versionpassed as a header has always been returned asApi-Version. Similarly,OSTypeis returned asOstype.This commit updates the documentation to reflect this behaviour and modifies the codebase to ensure that input strings are aligned with their canonical output values.
Closes: #49046 (comment)