> I have to code on the dark side and the code from microsoft > is really slow to the point where replacing it with socket > connections directly is about a 1/3 of the time.
Are you permitted to share example code?
> Does anyone know how a proxy works if I directly call a connect? Is
> it the same http codes just connecting to the proxy?
I've written the explanation below assuming you're talking about the
CONNECT method (it's a standard verb, like GET, POST and HEAD). Please
re-ask if you meant something else.
The proxy will give a HTTP response to the CONNECT method request. If
that response is anything other than 200, you don't get a tunnel and
your second question wouldn't matter.
For a 200 response, the proxy gets out of the way and just passes bytes
over the established tunnel. For a HTTP request over the tunnel, expect
HTTP response codes. For a TLS request, expect a TLS responses ;)
Here's an example of a HEAD request to google.com over a tunnel. The
first response (line 1 & 2) are from the local squid proxy and the
rest of the response lines are from Google.
## Install squid and permit a CONNECT to port 80.
$ sudo apt-get install squid
[ ... ]
$ sudo perl -i -pe 'm/acl SSL_ports port 443/ and print "acl SSL_ports port
80\n"' /etc/squid/squid.conf
$ sudo service squid reload
Reloading Squid configuration files.
done.
## Bogus port - an error from the proxy.
$ echo -ne "CONNECT google.com:25 HTTP/1.0\n\n" | tee /dev/stderr | nc
localhost 3128 | perl -pe 's/^/$.: /'
CONNECT google.com:25 HTTP/1.0
1: HTTP/1.0 403 Forbidden
2: Server: squid/2.7.STABLE9
[elided]
## Bogus URL - an error from the target server.
$ ( echo -ne "CONNECT google.com:80 HTTP/1.0\n\n"; sleep 1; echo -ne "HEAD
/does-not-exist HTTP/1.0\n\n" ) | tee /dev/stderr | nc localhost 3128 | perl
-pe 's/^/$.: /'
CONNECT google.com:80 HTTP/1.0
1: HTTP/1.0 200 Connection established
2:
HEAD /does-not-exist HTTP/1.0
3: HTTP/1.0 404 Not Found
4: Content-Type: text/html; charset=UTF-8
[elided]
## A valid, if boring, request.
$ ( echo -ne "CONNECT google.com:80 HTTP/1.0\n\n"; sleep 1; echo -ne "HEAD
/ HTTP/1.0\n\n" ) | tee /dev/stderr | nc localhost 3128 | perl -pe 's/^/$.: /'
CONNECT google.com:80 HTTP/1.0
1: HTTP/1.0 200 Connection established
2:
HEAD / HTTP/1.0
3: HTTP/1.0 302 Found
4: Location: http://www.google.com.au/[elided]
5: Cache-Control: private
6: Content-Type: text/html; charset=UTF-8
[elided]
## Do the cleanup.
$ sudo apt-get purge --auto-remove squid
$ sudo rm -r /var/spool/squid
--
Mark Suter http://zwitterion.org/ | I have often regretted my
email addr <[email protected]> | speech, never my silence.
mobile 0411 262 316 gpg FB1BA7E9 | Xenocrates (396-314 B.C.)
signature.asc
Description: Digital signature
-- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
