X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_event%2FAction%2Fhttp.pm;h=72a345d6b1735b578871ed5b3361f76e451a217a;hb=cd3719db530b4bffc1f2fe860bbc7a52f4b2235c;hp=b8715a7148f4695cf30118d1aad616eadbcccc37;hpb=376794a00e837317e35fefd61a29ab58c0303b35;p=freeside.git diff --git a/FS/FS/part_event/Action/http.pm b/FS/FS/part_event/Action/http.pm index b8715a714..72a345d6b 100644 --- a/FS/FS/part_event/Action/http.pm +++ b/FS/FS/part_event/Action/http.pm @@ -1,12 +1,17 @@ package FS::part_event::Action::http; +use base qw( FS::part_event::Action ); use strict; -use base qw( FS::part_event::Action ); +use vars qw( $me ); +use Data::Dumper; +use IO::Socket::SSL; use LWP::UserAgent; use HTTP::Request::Common; -use JSON::XS; +use Cpanel::JSON::XS; use FS::Misc::DateTime qw( iso8601 ); +$me = '[FS::part_event::Action::http]'; + #sub description { 'Send an HTTP or HTTPS GET or POST request'; } sub description { 'Send an HTTP or HTTPS POST request'; } @@ -37,6 +42,10 @@ sub option_fields { type => 'textarea', }, #'response_error_param' => 'Response error parameter', + 'debug' => { label => 'Enable debugging', + type => 'checkbox', + value => 1, + }, ); } @@ -60,10 +69,17 @@ sub do_action { ( $field, $value ); } split(/\n/, $self->option('content') ); + if ( $self->option('debug') ) { + warn "[$me] $_: ". $content{$_}. "\n" foreach keys %content; + } + my $content = encode_json( \%content ); my @lwp_opts = (); - push @lwp_opts, 'ssl_opts'=>{ 'verify_hostname'=>0 } + push @lwp_opts, 'ssl_opts' => { + verify_hostname => 0, + SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE, + } if $self->option('ssl_no_verify'); my $ua = LWP::UserAgent->new(@lwp_opts); @@ -73,6 +89,9 @@ sub do_action { Content => $content, ); + if ( $self->option('debug') ) { + #XXX dump raw request for debugging + } my $response = $ua->request($req); die $response->status_line if $response->is_error;