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

Websocket support. #2

Open
cheako opened this Issue Aug 3, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@cheako

cheako commented Aug 3, 2017

I was working on Tor2web, a client of twisted web. I discover that to move forward I'd need iResponce to expose the socket or something to read/write on. Once it's necessary to edit twisted-web I might as well go all out and at least partially implement Websockets.

Here is what I did for Tor2web It's incomplete, I was reading twisted-web and discovered the masked interface. Here is a good reference for Websockets at a protocol level, it does say server but if you'r not working in Javascript this is the document u need to read.

Here is what I'd envision for an interface, knowing only a little Python and almost no twisted.

  1. Upon receiving the response headers indicating a change of protocol(connection: upgrade). Remove the socket from any connection pool, as it can't ever be used for http. The connection will be upgraded until it's closed.

  2. Expose a socket interface in the iResponse class, it could be the class itself or an attribute. This could be a copy of the twisted socket interface or even that interface itself. With at least.
    a. onRead callback.
    b. Write.
    c. Close.
    d. onClose callback.
    e. onError, ect.

The api does not NEED a method to determine if the connection was upgraded, since the headers indicate as much. However to prevent attempts to access the Websocket API when it's not available a python(ish) method for detecting as much I'll leave to your discretion.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment