-
Notifications
You must be signed in to change notification settings - Fork 77
Preserve header casing #103
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
Closed
tomchristie
wants to merge
9
commits into
python-hyper:master
from
tomchristie:preserve-header-casing
Closed
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2b94ba4
Headers becomes a type of Sequence, rather than a raw, mutable list.
tomchristie ad75a8c
Write headers from headers.raw(), but continue to use lower-casing
tomchristie 3641ffd
Use title casing in get_comma_header/set_comma_header usages
tomchristie 5cac0b4
Preserve header casing in I/O bytes
tomchristie edf88cb
Python 2 support
tomchristie 0356d32
Fix __getitem__ implementation
tomchristie 054f0ca
Preserve header casing using tuple-like Header instances
tomchristie 8cafe02
Minimize change footprint
tomchristie a0eaaf8
Minimize change footprint
tomchristie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious about this. It seems it would return a list of the triplet where elsewhere
raw
implies the name that came over the wire. This should be clearer about what it is returningThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also wonder about the wisdom of having a headers sequence without structured single-header data
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure what you mean here. Are you saying "If you're returning a three-tuple from this interface then let's have it use a named-tuple" or something else?
Perhaps a marginally different interface for us to expose here would not be
.raw() -> (<lowercase name>, <raw name>, <value>)
, but instead expose just.raw_items() -> (<raw name>, <value>)
Perhaps that'd address the naming/intent slightly better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking of having a class that encapsulates a
Header
and then having the collection ofHeaders
use that. A namedtuple could work fine as well. All that said, I get that tuples may be a smidge faster and that these are internal implementation details. Speaking from having worked on header collection objects in urllib3 in the past, these tuples can drive maintainers to pull out their hair (as well as future folks trying to update/extend the behaviour).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, for something that remains compatible with the existing API I think the options here are...
Headers
sequence, that exposes the extra information in a.raw_items()
interface or similar, that returns a two-tuple of(case-sensitive-name, value)
for usages that require the raw casing info.Headers
sequence, the returnsHeader
instances, that can iterate as two-tuples, but also expose.name
,.case_sensitive_name
and.value
attributes, which are available for usages that require the raw casing info.Or some variation on those. (Eg. this PR which currently has
.raw()
returning the three-tuple of info.)Personally I'm fairly agnostic, as both the above options seem reasonable enough. The
Header
case has the most extra overhead, since it creates and accesses a per-header instance rather than the plain tuple, while I wouldn't expect the.raw_items()
approach to introduce anything really noticeable, but I could run through some timings on each of the options to help better inform our options.