-
Notifications
You must be signed in to change notification settings - Fork 160
encode/httpx#1214 prefer sending outbound cookies separately to improve headers compression #1275
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
encode/httpx#1214 prefer sending outbound cookies separately to improve headers compression #1275
Conversation
if isinstance(header, HeaderTuple): | ||
yield header.__class__(header[0], cookie_val) | ||
else: | ||
yield header[0], cookie_val |
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.
At this point, what are the trade-offs to simply always create HeaderTuple
's?
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.
Since we use the same approach in
Lines 549 to 552 in c7f967d
if isinstance(header, HeaderTuple): | |
yield header.__class__(header[0].strip(), header[1].strip()) | |
else: | |
yield (header[0].strip(), header[1].strip()) |
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 sure about that, but I see that all outbound cookies are handled using this pattern: isinstance(header, HeaderTuple): ...
Lines 534 to 538 in 63b6b97
for header in headers: | |
if isinstance(header, HeaderTuple): | |
yield header.__class__(header[0].lower(), header[1]) | |
else: | |
yield (header[0].lower(), header[1]) |
Lines 548 to 552 in 63b6b97
for header in headers: | |
if isinstance(header, HeaderTuple): | |
yield header.__class__(header[0].strip(), header[1].strip()) | |
else: | |
yield (header[0].strip(), header[1].strip()) |
Also I'm not sure about using NeverIndexedHeaderTuple
(e.g. how it can negatively affect compression)
Question for some context: if a client sends Cookie headers that are already split does h2 combine them somewhere or will the split header fields be encoded as expected? |
@sethmlarson I asked myself the same thing, and found this: Lines 583 to 603 in c7f967d
|
as a first step to a review, I fixed our project CI (which was a challenge by itself). I don't see any obvious issues with the code itself - though I still need time to think and read through the spec and implications. Happy to hear other thoughts in the mean time! @cdeler you said:
I don't see an "option" in your PR - its "always on"? |
48f26a2
to
65b719c
Compare
…to improve headers compression
65b719c
to
a48a2fe
Compare
Hello @Kriechi
I don't think so (because RFC says "may") :-) , so that I updated the PR adding |
LGTM! |
Hello, |
According to the rfc7540#section-8.1.2.5,
The
h2
framework is used by thehttpx
client, and some users require to have an ability to send cookies via separate headers to follow http2 practice. Or at least to make this option configurable (more: encode/httpx#1214).As
h2
decides how to properly send data over the transport,h2
seems to be a right place to add an ability to split the cookie headers. Also the opposite functionality is added to the inbound cookies processing (ref).Notes:
I have concerns about my PR, may be you can help me with suggestings: