Clarify HTTPFields name subscript get/set semantics - #131
Open
ZayanKhan-12 wants to merge 1 commit into
Open
Conversation
The doc comment said "If multiple fields with the same name exist, they are concatenated with commas", without saying it describes only the getter. It was read as the setter appending fields (apple#94), when the setter actually replaces all fields with the name. Document the getter and setter behaviors separately and point at subscript(values:) for setting multiple fields. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Motivation
Resolves the confusion in #94. The doc comment on
subscript(_: HTTPField.Name)says "If multiple fields with the same name exist, they are concatenated with commas…" without stating that this describes only the getter. As #94 shows, it can be read as the setter appending a field per assignment — when the setter actually replaces all existing fields with that name (andnilremoves them), as @guoye-zhang clarified in that issue.Modifications
Split the behavior description into explicit "when reading" / "when setting" sentences and cross-reference
subscript(values:)for setting multi-value fields. Documentation-only; no code changes.Result
The subscript's replace-on-set semantics are stated where users first look, closing the gap that prompted #94.
🤖 Generated with Claude Code