Why does the LWP :: UserAgent GET request terminate with HTTPS?

Here is my code

#!/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'] ); $ua->proxy(['http', 'https'], 'http://proxy:8080/'); my $page = $ua->get($myurl); die "Error $myurl\n ", $page->status_line, "\n Aborting" unless $page->is_success; print "Success", $page1->content_type, " document!\n"; 

He returns

 Error at https://www.redhat.com 400 Bad Request Aborting at test.pl line 30. 

what's wrong?

Edit:

Apparently Its a bug . But the workaround does not work for me.

+1
source share
4 answers

Ha! I got an answer!

1) remove the '/' after the ENV port {HTTPS_PROXY}

2) Apparently, the LWP proxy sends GET requests instead of CONNECT requests, so use the Crypt :: SSLeay proxy system by simply setting the environment variable and deleting the proxy command.

+1
source

On some systems, for example. Debian, you need to install the appropriate SSL library for this. Error messages on these systems may sometimes be slightly skipped. I think the Debian package would be libnet-ssleay-perl.

+1
source

I just downloaded the LWP :: Protocol :: connect module in CPAN. This module adds the missing support for the HTTP / CONNECT method in LWP.

  use LWP::UserAgent; $ua = LWP::UserAgent->new(); $ua->proxy('https', 'connect://proxyhost.domain:3128/'); $ua->get('https://www.somesslsite.com'); 

With this module you can use the usual implementation of IO :: Socket :: SSL for LWP> = 6.00.

+1
source

It looks like your proxy server is not accepting HTTPS connections. Have you tried setting it up in your favorite browser and viewing the url?

0
source

All Articles