fix: Make Headers subclass Mapping - #233
Merged
Merged
Conversation
hoodmane
force-pushed
the
hoodmane/httpmessage-mapping
branch
2 times, most recently
from
August 27, 2026 22:31
3bee1ad to
af5df27
Compare
3 tasks
ryanking13
reviewed
Aug 28, 2026
dom96
approved these changes
Aug 28, 2026
dom96
left a comment
Contributor
There was a problem hiding this comment.
Agreed with Gyeongjae, approving to unblock
hoodmane
force-pushed
the
hoodmane/httpmessage-mapping
branch
from
August 28, 2026 18:23
af5df27 to
cc5823a
Compare
`HTTPMessage` implements all the methods needed to be considered a `Mapping` but it does not register itself as a mapping. If we try to construct a Flask response and pass an `HTTPMessage` as a header, it fails to construct because it expects either: 1. a `Mapping` (in which case it iterates over mapping.items()), or 2. an iterable of key/value pairs If you iterate a `Mapping` directly, you only get the keys, so it doesn't work correctly because `HTTPMessage` isn't a `Mapping`
hoodmane
force-pushed
the
hoodmane/httpmessage-mapping
branch
from
August 28, 2026 18:26
cc5823a to
b9925ef
Compare
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.
HTTPMessageimplements all the methods needed to be considered aMappingbut it does not register itself as a mapping. If we try to construct a Flask response and pass anHTTPMessageas a header, it fails to construct because it expects either:Mapping(in which case it iterates over mapping.items()), orIf you iterate a
Mappingdirectly, you only get the keys, so it doesn't work correctly becauseHTTPMessageisn't aMapping.I'm not really sure we should be using
http.client.HTTPMessageat all here, I'd rather we had our ownHeadersclass. But given we are using it I think this is a clear improvement.