cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

question: ssl through proxies

From: Gaetano Giunta <giunta.gaetano_at_sea-aeroportimilano.it>
Date: Tue, 5 Sep 2006 14:47:03 +0200

Hello.

I just discovered the joys of http 1.0 extension for tunneling ssl through proxies.
http://curl.haxx.se/rfc/draft-luotonen-web-proxy-tunneling-01.txt

I maintain some http client code, that takes advantage of curl when available. It should properly parse responses that gotten back from https-connected web servers via a tunnelling proxy.

Do you think it is correct to use this check to extract the http headers inserted by the proxy in such a situation?

                // Support "web-proxy-tunelling" connections for https through proxies
                                if(preg_match('/^HTTP\/1\.[0-1] 200 Connection established/', $data))
                                {
                                        // Look for CR/LF or simple LF as line separator,
                                        // (even though it is not valid http)
                                        $pos = strpos($data,"\r\n\r\n");
                                        if($pos || is_int($pos))
                                        {
                                                $bd = $pos+4;
                                        }
                                        else
                                        {
                                                $pos = strpos($data,"\n\n");
                                                if($pos || is_int($pos))
                                                {
                                                        $bd = $pos+2;
                                                }
                                                else
                                                {
                                                        // No separation between response headers and body: fault?
                                                        $bd = 0;
                                                }
                                        }
                

the part that leaves me most wondering is checking for the string "Connection established": do you happen to know some proxies that use slight variations on the formula?

Any other known quirks? Do I risk loosing some useful information if I discard all http headers sent by the proxy itself?

Note that curl apparently works, since it gives no errors in retrieving the response (and I need to get back form curl a response with full http headers included).

Thanks
Gaetano Giunta

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-09-05