summary refs log tree commit diff
diff options
context:
space:
mode:
authorTim Bunce <Tim.Bunce@pobox.com>2010-11-23 11:39:34 +0000
committerTim Bunce <Tim.Bunce@pobox.com>2010-11-23 11:39:34 +0000
commit8f8958794f9dee563881ac0572d913f7378ce938 (patch)
treebfb1c0a08f4be14542c9ac30fa99b32a422730f8
parentChange deprecated AutoPrereq to recommended AutoPrereqs (diff)
downloadnet-http-spore-8f8958794f9dee563881ac0572d913f7378ce938.tar.gz
Throw exception by default if not is_success (but excepted takes precedence)
-rw-r--r--lib/Net/HTTP/Spore/Meta/Method.pm6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Net/HTTP/Spore/Meta/Method.pm b/lib/Net/HTTP/Spore/Meta/Method.pm
index db990ff..21d29e6 100644
--- a/lib/Net/HTTP/Spore/Meta/Method.pm
+++ b/lib/Net/HTTP/Spore/Meta/Method.pm
@@ -221,8 +221,10 @@ sub wrap {
         my $response = $self->http_request($env);
         my $code = $response->status;
 
-        die $response if ( $method->has_expected_status
-            && !$method->find_expected_status( sub { /$code/ } ) );
+        my $ok = ($method->has_expected_status)
+            ? $method->find_expected_status( sub { $_ eq $code } )
+            : $response->is_success; # only 2xx is success
+        die $response if not $ok;
 
         $response;
     };