[openssl-commits] [tools] master update

Richard Levitte levitte at openssl.org
Tue Jun 20 12:17:31 UTC 2017


The branch master has been updated
       via  138c39c5d96593910bbacb569c27e914a137eeb7 (commit)
      from  e61380828312a7803ea217d10866affedc4582ec (commit)


- Log -----------------------------------------------------------------
commit 138c39c5d96593910bbacb569c27e914a137eeb7
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Jun 20 14:17:24 2017 +0200

    OpenSSL-Query: use HTTP::Status::is_server_error
    
    It was reported that the HTTP::Response attribute is_server_error
    isn't available in older versions.  Instead of that attribute, use
    HTTP::Status::is_server_error on the server code.

-----------------------------------------------------------------------

Summary of changes:
 OpenSSL-Query/lib/OpenSSL/Query/ClaREST.pm    | 13 ++-----------
 OpenSSL-Query/lib/OpenSSL/Query/PersonREST.pm | 21 ++++++---------------
 2 files changed, 8 insertions(+), 26 deletions(-)

diff --git a/OpenSSL-Query/lib/OpenSSL/Query/ClaREST.pm b/OpenSSL-Query/lib/OpenSSL/Query/ClaREST.pm
index 5cb4ae9..905fa64 100644
--- a/OpenSSL-Query/lib/OpenSSL/Query/ClaREST.pm
+++ b/OpenSSL-Query/lib/OpenSSL/Query/ClaREST.pm
@@ -13,6 +13,7 @@ package OpenSSL::Query::ClaREST;
 use Carp;
 use Moo;
 use OpenSSL::Query qw(-register-cla OpenSSL::Query::ClaREST -priority 1);
+use HTTP::Status qw(:is);
 use LWP::UserAgent;
 use URI::Encode qw(uri_encode uri_decode);
 use JSON::PP;
@@ -25,16 +26,6 @@ sub _build__clahandler {
   return LWP::UserAgent->new( keep_alive => 1 );
 }
 
-## Validation
-#sub BUILD {
-#  my $self = shift;
-#
-#  # print STDERR Dumper(@_);
-#  my $ua = $self->_clahandler;
-#  my $resp = $ua->get($self->base_url);
-#  croak "Server error: ", $resp->message if $resp->is_server_error;
-#}
-
 sub has_cla {
   my $self = shift;
   my $id = shift;
@@ -44,7 +35,7 @@ sub has_cla {
   my $ua = $self->_clahandler;
   my $json = $ua->get($self->base_url . '/0/HasCLA/'
 		      . uri_encode($id, {encode_reserved => 1}));
-  croak "Server error: ", $json->message if $json->is_server_error;
+  croak "Server error: ", $json->message if is_server_error($json->code);
   return $json->code == 200;
 }
 
diff --git a/OpenSSL-Query/lib/OpenSSL/Query/PersonREST.pm b/OpenSSL-Query/lib/OpenSSL/Query/PersonREST.pm
index d4b78b3..bebc10a 100644
--- a/OpenSSL-Query/lib/OpenSSL/Query/PersonREST.pm
+++ b/OpenSSL-Query/lib/OpenSSL/Query/PersonREST.pm
@@ -14,6 +14,7 @@ use Carp;
 use Moo;
 use OpenSSL::Query qw(-register-person OpenSSL::Query::PersonREST -priority 1);
 use LWP::UserAgent;
+use HTTP::Status qw(:is);
 use URI::Encode qw(uri_encode uri_decode);
 use JSON::PP;
 use Data::Dumper;
@@ -25,22 +26,12 @@ sub _build__personhandler {
   return LWP::UserAgent->new( keep_alive => 1 );
 }
 
-## Validation
-#sub BUILD {
-#  my $self = shift;
-#
-#  # print STDERR Dumper(@_);
-#  my $ua = $self->_personhandler;
-#  my $resp = $ua->get($self->base_url);
-#  croak "Server error: ", $resp->message if $resp->is_server_error;
-#}
-
 sub list_people {
   my $self = shift;
 
   my $ua = $self->_personhandler;
   my $json = $ua->get($self->base_url . '/0/People');
-  croak "Server error: ", $json->message if $json->is_server_error;
+  croak "Server error: ", $json->message if is_server_error($json->code);
   return () unless $json->code == 200;
 
   my $decoded = decode_json $json->decoded_content;
@@ -55,7 +46,7 @@ sub find_person {
   my $ua = $self->_personhandler;
   my $json = $ua->get($self->base_url . '/0/Person/'
 			  . uri_encode($id, {encode_reserved => 1}));
-  croak "Server error: ", $json->message if $json->is_server_error;
+  croak "Server error: ", $json->message if is_server_error($json->code);
   return () unless $json->code == 200;
 
   my $decoded = decode_json $json->decoded_content;
@@ -74,7 +65,7 @@ sub find_person_tag {
 		      . uri_encode($id, {encode_reserved => 1})
 		      . '/ValueOfTag/'
 		      . uri_encode ($tag, {encode_reserved => 1}));
-  croak "Server error: ", $json->message if $json->is_server_error;
+  croak "Server error: ", $json->message if is_server_error($json->code);
   return undef unless $json->code == 200;
 
   my $decoded = decode_json $json->decoded_content;
@@ -93,7 +84,7 @@ sub is_member_of {
 		      . uri_encode($id, {encode_reserved => 1})
 		      . '/IsMemberOf/'
 		      . uri_encode ($group, {encode_reserved => 1}));
-  croak "Server error: ", $json->message if $json->is_server_error;
+  croak "Server error: ", $json->message if is_server_error($json->code);
   return 0 unless $json->code == 200;
 
   my $decoded = decode_json $json->decoded_content;
@@ -111,7 +102,7 @@ sub members_of {
 		      . '/0/Group/'
 		      . uri_encode($group, {encode_reserved => 1})
 		      . '/Members');
-  croak "Server error: ", $json->message if $json->is_server_error;
+  croak "Server error: ", $json->message if is_server_error($json->code);
   return () unless $json->code == 200;
 
   my $decoded = decode_json $json->decoded_content;


More information about the openssl-commits mailing list