-
Notifications
You must be signed in to change notification settings - Fork 194
Conversation
|
||
``hyper`` does not currently provide any way to limit the number of pushed | ||
streams, disable them altogether, or cancel in-progress pushed streams, although | ||
HTTP/2.0 allows all of these actions. |
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.
Before we add this functionality we must provide an API for disabling SERVER_PUSH, if only for the sake of requests which does not expect them.
This is another seriously impressive chunk of work @alekstorm, thankyou! As with the h2-10 work, I'll need a little while to review the code properly. We'll also have to bikeshed the API for a while I'm afraid, because it's something I'd like to get right the first time. =) |
|
||
# The response headers. These are determined upon creation, assigned | ||
# once, and never assigned again. | ||
self._headers = Headers(http_headers) |
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.
You're no longer removing :status
from the headers. We should do that because people don't expect to see it, and it's effectively a HTTP/2 implementation detail.
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.
Actually, extract_from_key_value_set
(above) does remove the specified keys from the key-value set - see the docstring in util.py
. It's easy to miss, I know :). Any ideas for a better name?
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.
The standard Python term for something that removes from a collection and returns would be pop
, so pop_from_key_value_set
is the suggested term. =) Obviously this'll need to be updated in #39.
…modify the set in-place
…er Response object pending further discussion
Hokay, rebased on Still TODO:
|
…fter the original response headers
A closer examination of the spec made me realize that These considerations are reflected in the new |
closes. Using this parameter is only recommended when it is known that all | ||
pushed streams, or a specific one, are of higher priority than the original | ||
response, or when also processing the original response in a separate thread | ||
(N.B. do not do this; ``hyper`` is not yet thread-safe):: |
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 think we should reword this section of the docs slightly. What matters about getpushes()
is that it returns an iterable of promises. The fact that the iterable is sometimes a list and sometimes a generator is mostly irrelevant. In fact, I think we should go further and always return a generator, even when we know we've got a list. That way we have a consistent API that prevents people doing silly things like calling len()
on a generator.
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.
Heh, reading through the code reveals that it is always a generator. In that case, just adjust the wording so that it's clearer that the return value is always a generator. Rather than the call itself blocking, it's whether the generator will block on future possible pushes. =)
Alright, more review comments inline. =) As for the two TODOs:
|
Also, looks like the tests need more code coverage. =) This is small, so it should be possible to achieve without introducing |
…hod to HTTP20Push
Okey doke, thanks for the continued excellence in reviewing. I've addressed all comments (let me know if you're happy with the new wording of the |
@@ -56,6 +61,8 @@ def __init__(self, host, port=None, window_manager=None, **kwargs): | |||
else: | |||
self.host, self.port = host, port | |||
|
|||
self._enable_push = enable_push |
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.
This is fine for now, but it'd be an interesting enhancement to have it be a property that causes the appropriate SETTINGS frame to be emitted.
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.
Agreed.
Alright, I pronounce this good-to-go. Let's get a green build and I'll merge the heck out of this. =D |
Bam, done. |
This is beautiful, I'm delighted to have this. Once again, you're just doing incredible work @alekstorm, thankyou so much. 🍰 👍 |
Just so you know @alekstorm, I'll be at PyCon from tomorrow through to Tuesday, which will reduce my responsiveness to pull requests and issues. Wanted to make sure you were aware. =) |
Sure, thanks for letting me know. Have fun! |
And thanks for the words of encouragement! They really do mean a lot :) |
They're 100% genuine. =) Based on your contributions over the last week or so, you've got everything you need to be a really valuable open source developer. You definitely have the technical skillset, you've demonstrated a willingness to work with maintainers to maintain style and project standards, you take code review well, and you're prepared to put in the work. You'd be a welcome contributor to any open source project you felt like. You've done awesome work on |
Depends on #39See the changes to
docs/source/advanced.rst
for an overview.Apologies for not getting approval for this ahead of time; you did clearly state in the documentation that server push wasn't a planned feature. However, I find it one of the most compelling parts of HTTP/2.0, and I think this a workable API for a single-threaded library. What do you think?
P.S. I also snuck in a fix for a bug that caused hyper to crash when trying to send a
WINDOW_UPDATE
frame to a server that had gone away with the stream half-closed on the remote side.