Skip to content

Support h2 WebSockets - #102

Closed
pgjones wants to merge 0 commit into
python-hyper:masterfrom
pgjones:master
Closed

pgjones wants to merge 0 commit into
python-hyper:masterfrom
pgjones:master

Conversation

@pgjones

@pgjones pgjones commented Jan 22, 2019

Copy link
Copy Markdown
Member

(Please don't merge)

This is a work in progress, but is presented here for comments.

Comment thread setup.py Outdated
],
install_requires=[
'h11 ~= 0.8.1', # means: 0.8.x where x >= 1
'h2 >= 3.1.0',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have an upper bound here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do 'h2 ~= 3.1'?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never really know/remember what ~= means.
I think h2 is a proper good semver citizen and we can use >=3.1,<4.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>=3.1,<4 is the same as ~=3.1 as I understand it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread wsproto/__init__.py Outdated

from .connection import ConnectionType
from .handshake import H11Handshake
from .handshake import H2Handshake, H11Handshake

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double space after import - or is this added by black/linting?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, just a mistake. Interesting that nothing fixed it...

Comment thread wsproto/__init__.py Outdated
if http_version is HTTPVersion.H11:
self.handshake = H11Handshake(connection_type)
else:
self.handshake = H2Handshake(connection_type)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about directly passing in a Handshake object instead of adding another enum?

Assuming we could pass in conn = WSConnection(... handshake=None), this would give us a nice way to disable handshakes and directly get a "ready-to-exchange-WS-frames" WSConnection object. Thoughts?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to pass a handshake_class rather than the enum, but I think the handshake=None won't work as you hope, however the Connection class itself is exactly a "ready-to-exchange-WS-frames" object. The reason is that the Connection object must know what extensions to use on initialization.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I remember we already talked about it.
Please add a good doc-string that explains the two different use cases - then I'm happy with it.

Comment thread wsproto/connection.py Outdated
yield CloseConnection(code=exc.code, reason=str(exc))


class H2Wrapper(object):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if anyone is actually going to use this wrapper in production.
Maybe this would be better moved to an example script?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you, I'll move

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I'm wrong, this is required if you use the H2Handshake.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move it into the H2Handshake then?
I have no strong opinion either way.

@pgjones pgjones closed this Mar 3, 2019
@pgjones pgjones changed the title WIP: Support h2 WebSockets Support h2 WebSockets Mar 3, 2019
This was referenced Mar 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants