Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Problems? Is your data what you think it is?
 
PerlMonks  

Re: LWP::Useragent GET fails with https

by wazoox (Prior)
on Sep 16, 2010 at 10:42 UTC ( #860336=note: print w/ replies, xml ) Need Help??


in reply to LWP::Useragent GET fails with https

If you define $ENV{HTTPS_PROXY} = 'http://proxy:8080'; you must NOT declare the proxy to LWP. So the correct code is:

#!/path/to/perl use strict; use LWP::UserAgent; use HTTP::Request::Common; use Crypt::SSLeay; $ENV{HTTPS_PROXY} = 'http://proxy:8080'; $ENV{HTTPS_DEBUG} = 1; my $myurl = "https://www.redhat.com"; my $ua = new LWP::UserAgent; $ua->cookie_jar( {} ); $ua->protocols_allowed( [ 'http','https'] ); # don't use https proxy with LWP! $ua->proxy(['http'], 'http://proxy:8080'); my $page = $ua->get($myurl); die "Error $myurl\n ", $page->status_line, "\n Aborting" unless $page->is_success; print "Success", $page->content_type, " document!\n";

Does this work for you?

Edit: corrected, removing the trailing slash from proxy url


Comment on Re: LWP::Useragent GET fails with https
Select or Download Code
Re^2: LWP::Useragent GET fails with https
by Anonymous Monk on Oct 18, 2011 at 15:33 UTC
    I'm still always getting "400 Bad Request" errors when I use the https proxy. If I try the code exactly as written, I get 500 errors so it's not using the https proxy at all via the environment variable.
      There was a slight mistake in my code example:
      $ENV{HTTPS_PROXY} = 'http://proxy:8080';
      Note the absence of trailing slash. It works for me, I've just got it running through my local squid proxy:
      [~/temp]$ ./test.pl SSL_connect:before/connect initialization SSL_connect:SSLv2/v3 write client hello A SSL_connect:SSLv3 read server hello A SSL_connect:SSLv3 read server certificate A SSL_connect:SSLv3 read server done A SSL_connect:SSLv3 write client key exchange A SSL_connect:SSLv3 write change cipher spec A SSL_connect:SSLv3 write finished A SSL_connect:SSLv3 flush data SSL_connect:SSLv3 read finished A Successtext/htmlcharset=ISO-8859-1 document!

      Please provide more information on your configuration. It works fine for me on Linux, running Perl 5.10.1 and LWP 5.835.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://860336]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2014-04-16 06:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (416 votes), past polls