Making a socket connection via a proxy server

Diez B. Roggisch deetsNOSPAM at web.de
Fri Jul 30 18:51:01 CEST 2004


Fuzzyman wrote:

> In a nutshell - the question I'm asking is, how do I make a socket
> conenction go via a proxy server ?
> All our internet traffic has to go through a proxy-server at location
> 'dav-serv:8080' and I need to make a socket connection through it.

Short answer: Its not possible.

The long answer: The proxy (dav-serv] isn't transparent - it is implemented
using http. That means that the browser knows about a proxp beeing in the
middle, and rewrites its request accordingly. An example:

we want to connect to http://foo.bar.com/foo.html

Usually, a http get looks like this: 

GET /foo.html HTTP/1.1

It is made by opening a connection to foo.bar.com on port 80.

Now if you add a proxy, things look like this:

GET http://foo.bar.com/foo.bar HTTP/1.1

And its sended to your proxy.

Notice the difference? Now the fully qualified url is sended, so the proxy
can make the request itself.

So because of this, there is no such thing like a socket connection through
a http-proxy.

If you still need a solution, you might be able to alter the tiny http proxy
to use http itself, instead of direct socket connections. Thus you might be
able to contact a proxy yourself.


--

Regards,

Diez B. Roggisch



More information about the Python-list mailing list