[Twisted-Python] connecting through an http proxy

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Tue Sep 1 17:51:40 EDT 2009

On 05:28 pm, hellfeuer at gmail.com wrote:
>First of let me say that I'm *very* new to twisted (I'm only trying to 
>an app that uses twisted). So sorry if this is a stupid question.
>The problem is I am behind an http proxy (with authentication), so I 
>need to
>connect through that proxy. The documentation doesn't help (me) much 
>neither does google (mostly because there are a million people who have
>created their own proxy server. This is not what I want to do).
>Any tips? The app is currently using ClientCreator (to make an SSL
>connection), but I'm willing to change all that if necessary.

If you're using twisted.web.client, then this will be tough, as there 
really isn't any support for HTTP proxies in that API.  You might be 
able to get something to work if you're using HTTPPageGetter directly, 
though - specify the right proxy authentication headers in the headers 
dictionary you give to the factory, make sure you put the full URI in 
the request path, etc.

If you're doing something else, then maybe you can elaborate on that. :)

The new HTTP client API which has not yet been part of any release will 
make this easier, but that doesn't help you if you need to work with an 
existing version of Twisted.


More information about the Twisted-Python mailing list