Permalink
Browse files

get() wasn't returning failure for non-2xx response codes, which was …

…causing test suite to fail
  • Loading branch information...
1 parent d9fd5db commit 6e7e54b8732aea451a0e1910df0b56ccb0907dae @neilb neilb committed Feb 22, 2012
Showing with 7 additions and 7 deletions.
  1. +7 −7 lib/LWP/Curl.pm
View
@@ -235,14 +235,14 @@ sub post {
$self->{retcode} = $self->{agent}->perform;
if ( $self->{retcode} == 0 ) {
+ my $code;
- #print("Transfer went ok\n");
- #print STDERR $content;
- return $content;
-
- #my $response_code = $selfcurl->getinfo(CURLINFO_HTTP_CODE);
- }
- else {
+ $code = $self->{agent}->getinfo(CURLINFO_HTTP_CODE);
+ if ($code =~ /^2/) {
+ return $content;
+ }
+ croak "$code request not successful\n";
+ } else {
croak( "An error happened: Host $url "
. $self->{agent}->strerror( $self->{retcode} )
. " ($self->{retcode})\n" );

0 comments on commit 6e7e54b

Please sign in to comment.