summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README3
-rw-r--r--lib/Net/HTTPS/Any.pm16
-rw-r--r--t/get-cryptssleay.t12
-rw-r--r--t/get-netssleay.t11
-rw-r--r--t/post-cryptssleay.t12
-rw-r--r--t/post-netssleay.t11
6 files changed, 38 insertions, 27 deletions
diff --git a/README b/README
index 8d67ccb..ec635b8 100644
--- a/README
+++ b/README
@@ -38,7 +38,8 @@ You can also look for information at:
COPYRIGHT AND LICENCE
-Copyright (C) 2008 Freeside Internet Services, Inc.
+Copyright (C) 2008 Freeside Internet Services, Inc. (http://freeside.biz)
+All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
diff --git a/lib/Net/HTTPS/Any.pm b/lib/Net/HTTPS/Any.pm
index c65c7d9..1812d06 100644
--- a/lib/Net/HTTPS/Any.pm
+++ b/lib/Net/HTTPS/Any.pm
@@ -2,11 +2,12 @@ package Net::HTTPS::Any;
use warnings;
use strict;
-use vars qw(@EXPORT_OK $ssl_module $skip_NetSSLeay);
+use vars qw(@ISA @EXPORT_OK $ssl_module $skip_NetSSLeay);
use Exporter;
use URI::Escape;
use Tie::IxHash;
+@ISA = qw( Exporter );
@EXPORT_OK = qw( https_get https_post );
BEGIN {
@@ -114,6 +115,8 @@ For example: 'text/namevalue',
CGI arguments, eitehr as a hashref or a listref. In the latter case, ordering
is preserved (see L<Tie::IxHash> to do so when passing a hashref).
+=item debug
+
=back
Returns a list consisting of the page content as a string, the HTTP
@@ -134,6 +137,7 @@ sub https_get {
$post_data = \%hash;
}
+ $opts->{'port'} ||= 443;
$opts->{"Content-Type"} ||= "application/x-www-form-urlencoded";
### XXX referer!!!
@@ -156,6 +160,8 @@ sub https_get {
import Net::SSLeay qw(get_https make_headers);
my $headers = make_headers(%headers);
+ $Net::SSLeay::trace = $opts->{'debug'} if exists $opts->{'debug'};
+
my( $res_page, $res_code, @res_headers ) =
get_https( $opts->{'host'},
$opts->{'port'},
@@ -180,6 +186,7 @@ sub https_get {
foreach my $hdr ( keys %headers ) {
$ua->default_header( $hdr => $headers{$hdr} );
}
+ $ENV{HTTPS_DEBUG} = $opts->{'debug'} if exists $opts->{'debug'};
my $res = $ua->request( GET($url) );
my @res_headers = map { $_ => $res->header($_) }
@@ -248,6 +255,7 @@ sub https_post {
$post_data = $opts->{'content'};
}
+ $opts->{'port'} ||= 443;
$opts->{"Content-Type"} ||= "application/x-www-form-urlencoded";
### XXX referer!!!
@@ -258,12 +266,14 @@ sub https_post {
$headers{'Host'} ||= $opts->{'host'};
if ( $ssl_module eq 'Net::SSLeay' ) {
-
+
import Net::SSLeay qw(post_https make_headers make_form);
my $headers = make_headers(%headers);
my $raw_data = ref($post_data) ? make_form(%$post_data) : $post_data;
+ $Net::SSLeay::trace = $opts->{'debug'} if exists $opts->{'debug'};
+
my( $res_page, $res_code, @res_headers ) =
post_https( $opts->{'host'},
$opts->{'port'},
@@ -289,6 +299,8 @@ sub https_post {
$ua->default_header( $hdr => $headers{$hdr} );
}
+ $ENV{HTTPS_DEBUG} = $opts->{'debug'} if exists $opts->{'debug'};
+
my $res;
if ( ref($post_data) ) {
$res = $ua->request( POST( $url, [%$post_data] ) );
diff --git a/t/get-cryptssleay.t b/t/get-cryptssleay.t
index 2b3babe..920f50a 100644
--- a/t/get-cryptssleay.t
+++ b/t/get-cryptssleay.t
@@ -5,17 +5,15 @@ use warnings;
use Test::More;
BEGIN {
+ plan( tests=>4 );
$Business::OnlinePayment::HTTPS::skip_NetSSLeay=1;
$Business::OnlinePayment::HTTPS::skip_NetSSLeay=1;
-}
-
-plan( tests=>4 );
-
-use_ok 'Net::HTTPS::Any';
+ use_ok 'Net::HTTPS::Any', 'https_get';
+};
#200
-my($content, $response, %headers) = Net::HTTPS::Any::https_get(
+my($content, $response, %headers) = https_get(
{ 'host' => 'secure.sisd.com',
'port' => 443,
'path' => '/freeside/index.html',
@@ -29,7 +27,7 @@ ok( length($content), 'Received content' );
#404
-my($content2, $response2, %headers2) = Net::HTTPS::Any::https_get(
+my($content2, $response2, %headers2) = https_get(
{ 'host' => 'secure.sisd.com',
'port' => 443,
'path' => '/freeside/notfound.html',
diff --git a/t/get-netssleay.t b/t/get-netssleay.t
index 9c83a0f..d36111d 100644
--- a/t/get-netssleay.t
+++ b/t/get-netssleay.t
@@ -4,13 +4,14 @@ use strict;
use warnings;
use Test::More;
-plan( tests=>4 );
-
-use_ok 'Net::HTTPS::Any';
+BEGIN {
+ plan( tests=>4 );
+ use_ok( 'Net::HTTPS::Any', qw( https_get ) );
+}
#200
-my($content, $response, %headers) = Net::HTTPS::Any::https_get(
+my($content, $response, %headers) = https_get(
{ 'host' => 'secure.sisd.com',
'port' => 443,
'path' => '/freeside/index.html',
@@ -24,7 +25,7 @@ ok( length($content), 'Received content' );
#404
-my($content2, $response2, %headers2) = Net::HTTPS::Any::https_get(
+my($content2, $response2, %headers2) = https_get(
{ 'host' => 'secure.sisd.com',
'port' => 443,
'path' => '/freeside/notfound.html',
diff --git a/t/post-cryptssleay.t b/t/post-cryptssleay.t
index 2ddda1b..2bf52ff 100644
--- a/t/post-cryptssleay.t
+++ b/t/post-cryptssleay.t
@@ -5,17 +5,15 @@ use warnings;
use Test::More;
BEGIN {
+ plan( tests=>4 );
$Business::OnlinePayment::HTTPS::skip_NetSSLeay=1;
$Business::OnlinePayment::HTTPS::skip_NetSSLeay=1;
-}
-
-plan( tests=>4 );
-
-use_ok 'Net::HTTPS::Any';
+ use_ok 'Net::HTTPS::Any', 'https_post';
+};
#200
-my($content, $response, %headers) = Net::HTTPS::Any::https_post(
+my($content, $response, %headers) = https_post(
{ 'host' => 'secure.sisd.com',
'port' => 443,
'path' => '/freeside/index.html',
@@ -29,7 +27,7 @@ ok( length($content), 'Received content' );
#404
-my($content2, $response2, %headers2) = Net::HTTPS::Any::https_get(
+my($content2, $response2, %headers2) = https_post(
{ 'host' => 'secure.sisd.com',
'port' => 443,
'path' => '/freeside/notfound.html',
diff --git a/t/post-netssleay.t b/t/post-netssleay.t
index e8cb2fd..14fc98b 100644
--- a/t/post-netssleay.t
+++ b/t/post-netssleay.t
@@ -4,13 +4,14 @@ use strict;
use warnings;
use Test::More;
-plan( tests=>4 );
-
-use_ok 'Net::HTTPS::Any';
+BEGIN {
+ plan( tests=>4 );
+ use_ok 'Net::HTTPS::Any', 'https_post';
+};
#200
-my($content, $response, %headers) = Net::HTTPS::Any::https_post(
+my($content, $response, %headers) = https_post(
{ 'host' => 'secure.sisd.com',
'port' => 443,
'path' => '/freeside/index.html',
@@ -24,7 +25,7 @@ ok( length($content), 'Received content' );
#404
-my($content2, $response2, %headers2) = Net::HTTPS::Any::https_get(
+my($content2, $response2, %headers2) = https_post(
{ 'host' => 'secure.sisd.com',
'port' => 443,
'path' => '/freeside/notfound.html',