Pragma has asked for the wisdom of the Perl Monks concerning the following question:

Setting $ua->proxy( https => 'http://x.x.x.x' ) does not work. Looking over a raw packet dump, I noticed that LWP::UserAgent doesn't employ the HTTP CONNECT method when going through an HTTP SSL proxy. Is this simply a capability that has not been designed into LWP? I googled everywhere for references to this problem, but cannot find anyone else complaining, leading me to believe that perhaps I'm missing something obvious.

Replies are listed 'Best First'.
Re: Using LWP through a proxy for HTTPS
by hsinclai (Deacon) on Oct 19, 2004 at 21:49 UTC
    ... but cannot find anyone else complaining
    Oh they're complaining all right - you just can't hear their muffled screams:)

    I have a squid proxy, where CONNECT is enabled for authorized entities. The following maneuver works through this proxy... tell me if it works for you (one thing, you have no port specified for the proxy, this might matter):

    my $finaldata; my @protocols = qw(http https ftp); my $query_url = 'https://www.etrade.com/'; my $ua = LWP::UserAgent->new( agent => 'yourstring'); $ua->protocols_allowed( \@protocols ); $ua->proxy('http://1.2.3.4:3128/'); my $response = $ua->get("$query_url", ':content_cb' => \&stitch, ); sub stitch { my($data, $response, $protocol) = @_; print $data; return $finaldata .= $data; }

    I am not a big fan of the LWP documentation.. it's not too clear in places ..

    HTH

    update,fix typo
      That code does not go through the proxy server for the https request; it creates a direct request to https://www.etrade.com.
        Really? It went right through my proxy - here's the squid access log snippet from earlier tonight

        1098222710.053 224973 1.2.3.4 TCP_MISS/200 1234 CONNECT www.etrade.com +:443 - DIRECT/12.153.224.22 - 1098222710.055 225359 1.2.3.4 TCP_MISS/200 25854 CONNECT www.etrade.co +m:443 - DIRECT/12.153.224.22 -
        1.2.3.4 is my source IP.
        I watched the requests go through at perl -e ' print scalar localtime(1098222710);'.. am I missing something?
Re: Using LWP through a proxy for HTTPS
by inman (Curate) on Oct 20, 2004 at 10:28 UTC