projects
/
Business-OnlinePayment.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7d0b3fb
)
new raw post
BUSINESS_ONLINEPAYMENT_3_00_03
author
ivan
<ivan>
Wed, 16 Mar 2005 10:46:15 +0000
(10:46 +0000)
committer
ivan
<ivan>
Wed, 16 Mar 2005 10:46:15 +0000
(10:46 +0000)
OnlinePayment.pm
patch
|
blob
|
history
OnlinePayment/HTTPS.pm
patch
|
blob
|
history
diff --git
a/OnlinePayment.pm
b/OnlinePayment.pm
index
73e4010
..
991bd7e
100644
(file)
--- a/
OnlinePayment.pm
+++ b/
OnlinePayment.pm
@@
-11,7
+11,7
@@
require 5.004;
#@EXPORT = qw();
#@EXPORT_OK = qw();
#@EXPORT = qw();
#@EXPORT_OK = qw();
-$VERSION = '3.00_0
2
';
+$VERSION = '3.00_0
3
';
sub VERSION { #Argument "3.00_01" isn't numeric in subroutine entry
local($^W)=0;
UNIVERSAL::VERSION(@_);
sub VERSION { #Argument "3.00_01" isn't numeric in subroutine entry
local($^W)=0;
UNIVERSAL::VERSION(@_);
diff --git
a/OnlinePayment/HTTPS.pm
b/OnlinePayment/HTTPS.pm
index
4e58a92
..
cacd2c1
100644
(file)
--- a/
OnlinePayment/HTTPS.pm
+++ b/
OnlinePayment/HTTPS.pm
@@
-9,7
+9,7
@@
use Tie::IxHash;
@ISA = qw( Business::OnlinePayment );
@ISA = qw( Business::OnlinePayment );
-$VERSION = '0.0
2
';
+$VERSION = '0.0
3
';
$DEBUG = 0;
$DEBUG = 0;
@@
-152,12
+152,14
@@
sub https_get {
}
}
-=item https_post HASHREF | FIELD => VALUE, ...
+=item https_post
SCALAR |
HASHREF | FIELD => VALUE, ...
-Accepts
parameters as either a hashref or a list of fields and values. In the
-
latter
case, ordering is preserved (see L<Tie::IxHash> to do so when passing a
+Accepts
form fields and values as either a hashref or a list. In the latter
+case, ordering is preserved (see L<Tie::IxHash> to do so when passing a
hashref).
hashref).
+Also accepts instead a simple scalar containing the raw content.
+
Returns a list consisting of the page content as a string, the HTTP response
code, and a list of key/value pairs representing the HTTP response headers.
Returns a list consisting of the page content as a string, the HTTP response
code, and a list of key/value pairs representing the HTTP response headers.
@@
-168,11
+170,15
@@
sub https_post {
#accept a hashref or a list (keep it ordered)
my $post_data;
#accept a hashref or a list (keep it ordered)
my $post_data;
- if ( ref($_[0]) ) {
+ if ( ref($_[0])
eq 'HASH'
) {
$post_data = shift;
$post_data = shift;
- } els
e
{
+ } els
if ( scalar(@_) > 1 )
{
tie my %hash, 'Tie::IxHash', @_;
$post_data = \%hash;
tie my %hash, 'Tie::IxHash', @_;
$post_data = \%hash;
+ } elsif ( scalar(@_) == 1 ) {
+ $post_data = shift;
+ } else {
+ die "https_post called with no params\n";
}
my $referer = ''; ### XXX referer!!!
}
my $referer = ''; ### XXX referer!!!
@@
-180,7
+186,7
@@
sub https_post {
$headers{'Referer'} = $referer if length($referer);
$headers{'Host'} = $self->server;
$headers{'Referer'} = $referer if length($referer);
$headers{'Host'} = $self->server;
- if ( $DEBUG ) {
+ if ( $DEBUG
&& ref($post_data)
) {
warn join('', map { " $_ => ". $post_data->{$_}. "\n" } keys %$post_data );
}
warn join('', map { " $_ => ". $post_data->{$_}. "\n" } keys %$post_data );
}
@@
-196,8
+202,10
@@
sub https_post {
}
#post_https( $self->server, $self->port, $self->path,
# $headers, make_form(%$post_data) );
}
#post_https( $self->server, $self->port, $self->path,
# $headers, make_form(%$post_data) );
+
+ my $raw_data = ref($post_data) ? make_form(%$post_data) : $post_data;
_my_post_https( $self->server, $self->port, $self->path,
_my_post_https( $self->server, $self->port, $self->path,
- $headers,
make_form(%$post_data)
);
+ $headers,
$raw_data
);
} elsif ( $ssl_module eq 'Crypt::SSLeay' ) {
} elsif ( $ssl_module eq 'Crypt::SSLeay' ) {
@@
-213,7
+221,16
@@
sub https_post {
}
my $ua = new LWP::UserAgent;
}
my $ua = new LWP::UserAgent;
- my $res = $ua->request( POST( $url, [ %$post_data ] ) );
+
+ my $res;
+ if ( ref($post_data) ) {
+ $res = $ua->request( POST( $url, [ %$post_data ] ) );
+ } else {
+ my $req =new HTTP::Request( 'POST' => $url );
+ $req->content_type('application/x-www-form-urlencoded');
+ $req->content($post_data);
+ $res = $ua->request($req);
+ }
#( $res->as_string, # wtf?
( $res->content,
#( $res->as_string, # wtf?
( $res->content,