[Twisted-Python] Proxy support through urllib2?
Hello everyone, Is it possible to use a proxy with Twisted? I can do this with urllib2 : proxy = urllib2.ProxyHandler({"http": "http://my.proxy.com:8080"}) opener = urllib2.build_opener(proxy) urllib2.install_opener(opener) will that suffice? I'd need SOCKSv5 and HTTP proxy support. Thanks, Gabriel
On 01:33 pm, gabriel.rossetti@arimaz.com wrote:
Hello everyone,
Is it possible to use a proxy with Twisted? I can do this with urllib2 :
proxy = urllib2.ProxyHandler({"http": "http://my.proxy.com:8080"}) opener = urllib2.build_opener(proxy) urllib2.install_opener(opener)
will that suffice? I'd need SOCKSv5 and HTTP proxy support.
This is one of the features the new HTTP client is intended to make easier to implement. The very short twisted.web.client.Agent is responsible for all the things which differ when connecting to a proxy instead of doing the usual thing. At some point, twisted.web.client should offer something like Agent which provides the proxy functionality. Do you want to take a stab at implementing it? Jean-Paul
exarkun@twistedmatrix.com wrote:
On 01:33 pm, gabriel.rossetti@arimaz.com wrote:
Hello everyone,
Is it possible to use a proxy with Twisted? I can do this with urllib2 :
proxy = urllib2.ProxyHandler({"http": "http://my.proxy.com:8080"}) opener = urllib2.build_opener(proxy) urllib2.install_opener(opener)
will that suffice? I'd need SOCKSv5 and HTTP proxy support.
This is one of the features the new HTTP client is intended to make easier to implement. The very short twisted.web.client.Agent is responsible for all the things which differ when connecting to a proxy instead of doing the usual thing. At some point, twisted.web.client should offer something like Agent which provides the proxy functionality. Do you want to take a stab at implementing it?
Jean-Paul
Ok, thanks for the info. I can have a try, right now we use Twisted 8.1.0 though, I have to get something working with that version first and then whe we've tested our app with version 9.0 I'll try. Gabriel
On Mon, Jan 11, 2010 at 7:33 AM, Gabriel Rossetti < gabriel.rossetti@arimaz.com> wrote:
Hello everyone,
Is it possible to use a proxy with Twisted? I can do this with urllib2 :
proxy = urllib2.ProxyHandler({"http": "http://my.proxy.com:8080"}) opener = urllib2.build_opener(proxy) urllib2.install_opener(opener)
will that suffice? I'd need SOCKSv5 and HTTP proxy support.
Thanks, Gabriel
When you say you want to "use a proxy with Twisted", do you mean that you want Your Twisted applicatino to provide a proxy to other applications, or do you mean that you want your Twisted application to use a (separate) proxy? Kevin Horn
Kevin Horn wrote:
On Mon, Jan 11, 2010 at 7:33 AM, Gabriel Rossetti
mailto:gabriel.rossetti@arimaz.com> wrote: Hello everyone,
Is it possible to use a proxy with Twisted? I can do this with urllib2 :
proxy = urllib2.ProxyHandler({"http": "http://my.proxy.com:8080"}) opener = urllib2.build_opener(proxy) urllib2.install_opener(opener)
will that suffice? I'd need SOCKSv5 and HTTP proxy support.
Thanks, Gabriel
When you say you want to "use a proxy with Twisted", do you mean that you want Your Twisted applicatino to provide a proxy to other applications, or do you mean that you want your Twisted application to use a (separate) proxy?
Kevin Horn
I mean have the Twisted app (client) connect to a server outside the network by going through an http proxy server, like it's often the caser in company networks. Gabriel
participants (3)
-
exarkun@twistedmatrix.com
-
Gabriel Rossetti
-
Kevin Horn