How to connect a socket to an http server through proxy? How to connect a socket to an http server through proxy? linux linux

How to connect a socket to an http server through proxy?


To use connections via proxy (or if they are implicitly proxy-fied), first you should connect to proxy, send a 'CONNECT' message with target host; proxy will establish connection and return you data.

Here is in steps:

  1. open socket to proxy host
  2. send 'CONNECT http://www.google.com:80 HTTP/1.0\r\n\r\n' string
  3. wait for recv

You must specify protocol (in our case is HTTP 1.0, non-chunked) with ending newline characters, so proxy knows how to communicate with end point.

You can find details about CONNECT method at http://www.ietf.org/rfc/rfc2817.txt


If you're specifically trying to bypass the proxy, you should talk to whoever administers your network to find out if that's even possible. If your first block of output is an attempt to connect to Google then it appears to me that there's some kind of transparent proxy on your network that you'll have to take special (and network-specific) steps to bypass.

Of course, if you're just interested in getting data, you could try following the redirect...