I was working on Tor2web, a client of twisted web. I discover that to move forward I'd need [iResponce](https://github.com/racker/python-twisted-web/blob/master/twisted/web/iweb.py...) 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](https://pastebin.com/MbHVvwNz) It's incomplete, I was reading twisted-web and discovered the masked interface. Here is a [good reference for Websockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebS...) 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.
On Fri, Aug 4, 2017 at 10:01 AM, Mike Mestnik < cheako+twistedmatrix@mikemestnik.net> wrote:
I was working on Tor2web, a client of twisted web. I discover that to
What are you trying to do? The subject of your message suggests you're interested in some kind of WebSocket support but I have trouble following the rest. If you want Twisted and WebSockets, take a look at this: https://github.com/crossbario/autobahn-python Jean-Paul
On Fri, Aug 4, 2017 at 9:11 AM, Jean-Paul Calderone <exarkun@twistedmatrix.com> wrote:
On Fri, Aug 4, 2017 at 10:01 AM, Mike Mestnik <cheako+twistedmatrix@mikemestnik.net> wrote:
I was working on Tor2web, a client of twisted web. I discover that to
What are you trying to do? The subject of your message suggests you're interested in some kind of WebSocket support but I have trouble following the rest.
If you want Twisted and WebSockets, take a look at this: https://github.com/crossbario/autobahn-python
I want twisted.web.client.Agent that will see the connection being upgraded and release the socket FOR websocket. Currently if you tried to use twisted.web.client.Agent with autobahn-python bad things would happen.
Jean-Paul
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
As the name suggests Tor2web is a proxy, it does not need to know anything about the Websocket protocol, it just needs to know the HTTP protocol and support it's Websocket aspect identified by the "connection: upgrade" header. Here is a patch I wrote that adds this support: https://pastebin.com/MbHVvwNz Notice the TODO, this is where changes to the twisted.web.client.Agent are needed... or to just do the HTTP without this helper library.
On Fri, Aug 4, 2017 at 11:29 AM, Mike Mestnik < cheako+twistedmatrix@mikemestnik.net> wrote:
On Fri, Aug 4, 2017 at 9:11 AM, Jean-Paul Calderone <exarkun@twistedmatrix.com> wrote:
On Fri, Aug 4, 2017 at 10:01 AM, Mike Mestnik <cheako+twistedmatrix@mikemestnik.net> wrote:
I was working on Tor2web, a client of twisted web. I discover that to
What are you trying to do? The subject of your message suggests you're interested in some kind of WebSocket support but I have trouble following the rest.
If you want Twisted and WebSockets, take a look at this: https://github.com/crossbario/autobahn-python
I want twisted.web.client.Agent that will see the connection being upgraded and release the socket FOR websocket. Currently if you tried to use twisted.web.client.Agent with autobahn-python bad things would happen.
Autobahn also has support for building WebSocket clients: http://autobahn.readthedocs.io/en/stable/websocket/programming.html#creating... Jean-Paul
Not what's needed here. On Fri, Aug 4, 2017 at 10:53 AM, Jean-Paul Calderone <exarkun@twistedmatrix.com> wrote:
On Fri, Aug 4, 2017 at 11:29 AM, Mike Mestnik <cheako+twistedmatrix@mikemestnik.net> wrote:
On Fri, Aug 4, 2017 at 9:11 AM, Jean-Paul Calderone <exarkun@twistedmatrix.com> wrote:
On Fri, Aug 4, 2017 at 10:01 AM, Mike Mestnik <cheako+twistedmatrix@mikemestnik.net> wrote:
I was working on Tor2web, a client of twisted web. I discover that to
What are you trying to do? The subject of your message suggests you're interested in some kind of WebSocket support but I have trouble following the rest.
If you want Twisted and WebSockets, take a look at this: https://github.com/crossbario/autobahn-python
I want twisted.web.client.Agent that will see the connection being upgraded and release the socket FOR websocket. Currently if you tried to use twisted.web.client.Agent with autobahn-python bad things would happen.
Autobahn also has support for building WebSocket clients:
http://autobahn.readthedocs.io/en/stable/websocket/programming.html#creating...
Jean-Paul
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
participants (2)
-
Jean-Paul Calderone
-
Mike Mestnik