in reply to Re^2: WWW::Mechanize with https and a proxy
in thread WWW::Mechanize with https and a proxy

Just an FYI, I've found I definitly need the SSLeay and env variable setting, otherwise it hangs (so I can confirm the above statement). At least I get something back when I include them, even if it is a 400 error. If this script works for others without a proxy, then I can only assume it's something wonky with our proxy, which is a bummer. I'll ping the internal help group again and report back if there's an update.
  • Comment on Re^3: WWW::Mechanize with https and a proxy

Replies are listed 'Best First'.
Re^4: WWW::Mechanize with https and a proxy
by Anonymous Monk on Apr 03, 2009 at 15:22 UTC

    OK, I just spent two hours figuring this out. Make sure you are using ssleay (not openssl)

    Here is the code to properly setup mechanize to use a private proxy:

    use WWW::Mechanize;
    my $proxy='proxy.host.net:8080';
    my $proxy_user='proxy_username';
    my $proxy_pass='proxy_password';
    $ENV{HTTPS_PROXY} = 'http://'.$proxy;
    $ENV{HTTPS_PROXY_USERNAME} = $proxy_user;
    $ENV{HTTPS_PROXY_PASSWORD} = $proxy_pass;
    my $mech = WWW::Mechanize->new();
    $mech->agent('Mozilla/5.0');
    $mech->proxy('http', 'http://'.$proxy_user.':'.$proxy_pass.'@'.$proxy);
    $mech->proxy('https', undef);
    $mech->get('https://www.somehost.com/');