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

Strawberry Perl 5.18.2/Windows 7
WWW::Mechanize or LWP::UserAgent behind a corporate firewall (no login required)

Connect via http works.
Connect via https results in an error
Sites tried: example.com, google.com, and slashdot.org.

Example code:

use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $mech->proxy(['http', 'https'], 'http://xx.xx.x.xx:xx'); print $mech->get("https://example.com");

Result from http: HTTP::Response=HASH(0x34001f0)
Result from https: Error GETing https://example.com: Server closed connection without sending any data back at <filename> line 4.

use LWP::UserAgent; $ua = LWP::UserAgent->new; $ua->proxy(['http', 'https'], 'http://xx.xx.x.xx:xx'); print $ua->get("https://example.com");

Result from http: HTTP::Response=HASH(0x2ef6bf8)
Result from https: Server closed connection without sending any data back at C:/strawberry/perl/vendor/lib/Net/HTTP/Methods.pm line 373.
(FWIW, line 373 is die() in sub read_response_headers.)

Please help me determine the cause of the error and to connect via https.

Update

"Server closed connection without sending any data back" means the proxy server. This is easily seen via telnet to the proxy server:

GET http://example.com/ HTTP/1.1 (2 newlines)

returns the page.

GET https://example.com/ HTTP/1.1 (2 newlines)

closes the connection.

rt://1894 Workarounds listed there.

  • Comment on [Solved] LWP/HTTPS/Proxy error: Server closed connection without sending any data back
  • Select or Download Code

Replies are listed 'Best First'.
Re: LWP/HTTPS/Proxy error: Server closed connection without sending any data back
by Corion (Patriarch) on Apr 30, 2014 at 13:49 UTC

    Depending on your version of IO::SSLeay (or whatever), LWP doesn't have much bearing on the proxy to be used for HTTPS. In one situation, the following worked:

    BEGIN { $ENV{HTTPS_PROXY} = 'http://myproxy.internal.corion:8080'; $ENV{HTTPS_PROXY_USERNAME} = 'Corion'; $ENV{HTTPS_PROXY_PASSWORD} = 'Corion'; }; use Crypt::SSLeay; use WWW::Mechanize; ...

      Thanx for the info. I tried it in both script and it did not help. :(