Showing with 34 additions and 6 deletions.
  1. +3 −3 lib/XML/Compile/SOAP/Daemon/PSGI.pm
  2. +31 −3 t/12fault_psgi.t
6 changes: 3 additions & 3 deletions lib/XML/Compile/SOAP/Daemon/PSGI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ sub _init($)
sub call($)
{ my ($self, $env) = @_;
my $res = eval { $self->_call($env) };
$@ ? [ RC_SERVER_ERROR, [Content_Type => 'text/plain'], [$@] ] : $res;
$@ ? [ RC_SERVER_ERROR, ['Content-Type' => 'text/plain'], [$@] ] : $res;
}

sub _call($;$)
Expand Down Expand Up @@ -107,8 +107,8 @@ sub _call($;$)
}

my $res = $req->new_response($rc,
{ Warning => "199 $msg"
, Content_Type => $mime
{ 'Warning' => "199 $msg"
, 'Content-Type' => $mime
}, $bytes);

if(my $pp = $self->{postprocess})
Expand Down
34 changes: 31 additions & 3 deletions t/12fault_psgi.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/perl
# Attempt to produce all errors for CGI backend
# Attempt to produce all errors for PSGI backend

use warnings;
use strict;
Expand All @@ -21,7 +21,7 @@ BEGIN
die $@ if $@;
}

plan tests => 11;
plan tests => 14;

require_ok('Plack::Test');
require_ok('HTTP::Request');
Expand Down Expand Up @@ -68,7 +68,7 @@ sub send_request($)
Plack::Test::test_psgi($app, sub {
my $cb = shift;
my $res = $cb->($req);
my $msg = $res->headers->header('Warning');
my $msg = $res->headers->header('Warning') || '<empty>';
$msg =~ s/^199 //;
$answer = join "\n",
$res->code,
Expand Down Expand Up @@ -196,3 +196,31 @@ text/xml
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
__EXPECTED

my $daemon2 = XML::Compile::SOAP::Daemon::PSGI->new;
isa_ok($daemon2, 'XML::Compile::SOAP::Daemon::PSGI');

$app = $daemon2->run({preprocess => sub { die "BOOM\n" }});
isa_ok($app, 'CODE');

### Internal error

my $ans8 = send_request <<__REQ8;
POST /a HTTP/1.0
Content-Type: text/xml
soapAction: ''
<me:Envelope xmlns:me="$soapenv">
<me:Body>
<me:something />
</me:Body>
</me:Envelope>
__REQ8

compare_answer($ans8, <<__EXPECTED, 'internal error');
500
<empty>
text/plain
BOOM
__EXPECTED