diff options
Diffstat (limited to 'BatchPayment/Transport/HTTPS.pm')
-rw-r--r-- | BatchPayment/Transport/HTTPS.pm | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/BatchPayment/Transport/HTTPS.pm b/BatchPayment/Transport/HTTPS.pm index fdb2c35..0eb783b 100644 --- a/BatchPayment/Transport/HTTPS.pm +++ b/BatchPayment/Transport/HTTPS.pm @@ -14,29 +14,36 @@ use Net::HTTPS::Any 0.10; with 'Business::BatchPayment::Transport'; has [ qw( host port get_path put_path ) ] => ( - is => 'ro', + is => 'rw', isa => 'Str' ); has 'content_type' => ( is => 'rw', isa => 'Str', - default => 'text/plain' + default => '', # application/x-www-form-urlencoded ); sub https_post { my $self = shift; my $path = shift; my $content = shift; - - warn "starting https_post...\n" if $self->debug; - my ( $page, $response, %reply_headers ) = Net::HTTPS::Any::https_post( + my %post = ( host => $self->host, port => $self->port, path => $path, - content => $content, - debug => ($self->debug >= 3), + debug => ($self->debug > 3 ? 1 : 0), + 'Content-Type' => $self->content_type ); + if (ref $content and ref $content eq 'HASH') { + $post{'args'} = $content; + } else { + $post{'content'} = $content; + } + + warn "starting https_post...\n" if $self->debug; + my ( $page, $response, %reply_headers ) = Net::HTTPS::Any::https_post(%post); + warn "PAGE:\n$page\n\nRESPONSE:\n$response\n\n" if $self->debug >= 2; return ($page, $response, %reply_headers); } |