On Mon Dec 19 13:34:42 2011, JGMYERS wrote:
Show quoted text> On Mon Dec 19 06:59:36 2011, Yusuf wrote:
> > After going thru your solution I did the necessary changes in the perl
> > modules but the https requests are failing via proxy.
>
> I don't see the "ConnectProxy" and "UA" parameters added by the patch to
> LWP-Protocol-https, so it doesn't look like you applied all of the
patches.
Thanks for your reply.
As suggested I have applied the following patches in the order given
below.
1. lwp-ssl.patch
2. Net-HTTP-6.01-httpsproxy.patch
3. LWP-Protocol-https-6.02-httpsproxy.patch
4. libwww-perl-6.03-httpsproxy.patch
But still I am not able to connect via proxy.
Thanks for your valued help.
Regards,
My test program is:
#! /opt/bin/perl5 -w
use LWP::UserAgent;
$ua = LWP::UserAgent->new();
$ua->proxy(['https', 'http', 'ftp'] => "
http://196.1.1.14:8080");
$ua->protocols_allowed([ 'https', 'http', 'ftp' ]);
$req = new HTTP::Request 'GET' => '
https://www.cmie.biz/updates/af/';
$req->header('Accept' => '*/*');
# send request
$res = $ua->request($req);
# check the outcome
if ($res->is_success) {
print $res->content;
} else {
print "Error: " . $res->status_line . "\n";
}
Debug outputs:
Case 1: Comment subroutine "_request" in LWP/Protocol/https.pm
with the following patched "new" in LWP/Protocol/https.pm (patch
is to enable debugging).
Note: Squid Proxy Server reports the following in its access_log
"1324363103.407 0 196.1.1.28 TCP_DENIED/403 778 CONNECT
196.1.1.14:8080 - NONE/- text/html"
sub new
{
my $self = shift();
my $arg_hash = { @_ };
print STDERR "x" x 80, "\n";
print STDERR "LWP::Protocol::https new -> value of arg_hash
before assigning=", Dumper($arg_hash), "\n";
print STDERR "x" x 80, "\n";
my $proxy = delete $arg_hash->{ConnectProxy};
my $ua = delete $arg_hash->{UA};
if ($proxy) {
my $uri = $proxy->clone;
print STDERR "uri=", Dumper($uri), "\n";
print STDERR "x" x 80, "\n";
$uri->path($arg_hash->{PeerAddr}.':'.$arg_hash->{PeerPort});
my $response = $ua->request(HTTP::Request->new('CONNECT',
$uri));
return $self->error($response->status_line) if
$response->is_error;
eval { $response->{client_socket}->blocking(1); };
return $self->start_SSL($response->{client_socket},
$arg_hash);
}
return $self->SUPER::new(%$arg_hash);
}
Output of Case 1:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
LWP::Protocol::https new -> value of arg_hash before assigning=$VAR1 = {
'Proto' => 'tcp',
'SSL_verifycn_scheme' => 'www',
'PeerPort' => 443,
'SSL_ca_path' => '/etc/ssl/certs',
'SSL_verify_mode' => 1,
'LocalAddr' => undef,
'KeepAlive' => '',
'PeerAddr' => 'www.cmie.biz',
'SendTE' => 1,
'UA' => bless( {
'max_redirect' => 7,
'ssl_opts' => {
'verify_hostname' => 1
},
'protocols_forbidden' => undef,
'show_progress' => undef,
'handlers' => {
'response_header' => bless( [
{
'owner' => 'LWP::UserAgent::parse_head',
'callback' => sub { "DUMMY" },
'm_media_type' => 'html',
'line' => 'LWP/UserAgent.pm:658'
}
], 'HTTP::Config' ),
'request_preprepare' => bless( [
{
'owner' => 'LWP::UserAgent::proxy',
'callback' => sub { "DUMMY" },
'line' => 'LWP/UserAgent.pm:966'
}
], 'HTTP::Config' )
},
'no_proxy' => [],
'protocols_allowed' => [
'https',
'http',
'ftp'
],
'local_address' => undef,
'use_eval' => 1,
'requests_redirectable' => [
'GET',
'HEAD'
],
'timeout' => 180,
'def_headers' => bless(
{
'user-agent' => 'libwww-perl/6.03'
}, 'HTTP::Headers' ),
'proxy' => {
'ftp' => '
http://196.1.1.14:8080',
'http' => '
http://196.1.1.14:8080',
'https' => '
http://196.1.1.14:8080'
},
'max_size' => undef
}, 'LWP::UserAgent' ),
'ConnectProxy' =>
bless( do{\(my $o = '
http://196.1.1.14:8080')}, 'URI::http' ),
'Timeout' => 180
};
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
uri=$VAR1 = bless( do{\(my $o = '
http://196.1.1.14:8080')}, 'URI::http' );
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Error: 500 Can't connect to www.cmie.biz:443
Case 2: With "request" in LWP/Protocol/https.pm
Output of Case 2:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
LWP::Protocol::https new -> value of arg_hash before assigning=$VAR1 = {
'Proto' => 'tcp',
'SSL_verifycn_scheme' => 'www',
'PeerPort' => 443,
'SSL_ca_path' => '/etc/ssl/certs',
'SSL_verify_mode' => 1,
'LocalAddr' => undef,
'KeepAlive' => '',
'PeerAddr' => 'www.cmie.biz',
'SendTE' => 1,
'UA' => bless( {
'max_redirect' => 7,
'ssl_opts' => {
'verify_hostname' => 1
},
'protocols_forbidden' => undef,
'show_progress' => undef,
'handlers' => {
'response_header' => bless( [
{
'owner' => 'LWP::UserAgent::parse_head',
'callback' => sub { "DUMMY" },
'm_media_type' => 'html',
'line' => 'LWP/UserAgent.pm:658'
}
], 'HTTP::Config' ),
'request_preprepare' => bless( [
{
'owner' => 'LWP::UserAgent::proxy',
'callback' => sub { "DUMMY" },
'line' => 'LWP/UserAgent.pm:966'
}
], 'HTTP::Config' )
},
'no_proxy' => [],
'protocols_allowed' => [
'https',
'http',
'ftp'
],
'local_address' => undef,
'use_eval' => 1,
'requests_redirectable' => [
'GET',
'HEAD'
],
'timeout' => 180,
'def_headers' => bless( {
'user-agent' =>
'libwww-perl/6.03'
}, 'HTTP::Headers' ),
'proxy' =>
{
'ftp' => '
http://196.1.1.14:8080',
'http' => '
http://196.1.1.14:8080',
'https' => '
http://196.1.1.14:8080'
},
'max_size' => undef
}, 'LWP::UserAgent' ),
'ConnectProxy' => undef,
'Timeout' => 180
};
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Error: 500 Can't connect to www.cmie.biz:443 (Connection timed out)