Search code examples
perlwww-mechanize

Active perl Mechanize bad request error


I am trying to get https using Mechanize but failed with:

use strict;
use warnings;

use IO::Socket::SSL;
use WWW::Mechanize;

my $mech = WWW::Mechanize->new;
$mech->proxy(['https','http'], 'http://proxy:8080/');
$mech->get('https://www.google.com');

print $mech->content;

Error:

Error GETing https://www.google.com: Bad Request at perl4.pl line 9.

When I try to use LWP::UserAgent I am able to get https without any error:

use LWP::UserAgent;

my $ua  = LWP::UserAgent->new;
$ua->proxy(['https','http'], 'http://proxy:8080/');
$ua->get('https://www.google.com');

Can anyone help out with this?

Currently using Mechanize 1.72


Solution

  • I have installed LWP-Protocol-connect-6.03 and connect to the proxy with

    $https_proxy = 'connect://proxy:8080/';
    

    It is working fine now :D