This is an automated email from the git hooks/post-receive script.

gregoa pushed a commit to annotated tag v1.17
in repository libnet-openid-common-perl.

commit 39192a53d71f8b547025a6cb3428356027201d65
Author: Roger Crew <c...@cs.stanford.edu>
Date:   Fri Apr 12 14:37:27 2013 -0700

    IndirectMessage->new now assumes CGI param() interface by default
    
    unifies CGI, Apache::Request, and Apache2::Request cases.
    This way, other frameworks that have similar objects (e.g., Mojo)
    are automatically supported.  Plack and Apache (i.e., Apache 1
    without libapreq) are now the only special cases.
---
 lib/Net/OpenID/IndirectMessage.pm | 40 ++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 22 deletions(-)

diff --git a/lib/Net/OpenID/IndirectMessage.pm 
b/lib/Net/OpenID/IndirectMessage.pm
index 1af63b3..20b9615 100644
--- a/lib/Net/OpenID/IndirectMessage.pm
+++ b/lib/Net/OpenID/IndirectMessage.pm
@@ -24,11 +24,6 @@ sub new {
         $getter = sub { $what->{$_[0]}; };
         $enumer = sub { keys(%$what); };
     }
-    elsif (UNIVERSAL::isa($what, "CGI")) {
-        # CGI automatically does what we need when method is POST
-        $getter = sub { scalar $what->param($_[0]); };
-        $enumer = sub { $what->param; };
-    }
     elsif (ref $what eq "Apache") {
         my %get;
         if ($what->method eq 'POST') {
@@ -40,19 +35,21 @@ sub new {
         $getter = sub { $get{$_[0]}; };
         $enumer = sub { keys(%get); };
     }
-    elsif ((ref $what eq "Apache::Request") || (ref $what eq 
"Apache2::Request")) {
-        # Apache::Request includes the POST and GET arguments in ->param
-        # when doing a POST request, which is close enough to what
-        # the spec requires.
-        $getter = sub { scalar $what->param($_[0]); };
-        $enumer = sub { $what->param; };
-    }
     elsif (ref $what eq "Plack::Request") {
         my $p = $what->method eq 'POST' ? $what->body_parameters : 
$what->query_parameters;
         $getter = sub { $p->get($_[0]); };
         $enumer = sub { keys %{$p}; };
     }
-    elsif (ref $what eq "CODE") {
+    elsif (ref $what ne "CODE") {
+        # assume an object that follows the CGI interface and has a param() 
method
+        # CGI does the right thing and omits query parameters if this is a POST
+        # others (Apache::Request, Apache2::Request) mix query and body params.
+        $getter = sub { scalar $what->param($_[0]); };
+        $enumer = sub { $what->param; };
+    }
+
+    else {
+        # CODE reference
         my @keys = ();
         my $enumerated;
         $getter = $what;
@@ -79,10 +76,6 @@ sub new {
             return @keys;
         }
     }
-    else {
-        $what = 'undef' if !defined $what;
-        Carp::croak("Unknown parameter type ($what)");
-    }
     $self->{getter} = $getter;
     $self->{enumer} = $enumer;
 
@@ -257,13 +250,12 @@ for Simple Registration.
 
 This class can operate on
 a normal hashref,
-a L<CGI> object,
+a L<CGI> object or any object with a C<param> method that behaves similarly
+(L<Apache::Request>, L<Apache2::Request>, L<Mojo::Parameters>,...),
 an L<Apache> object,
-an L<Apache::Request> object,
-an L<Apache2::Request> object,
 a L<Plack::Request> object, or
-an arbitrary C<CODE> ref that takes a key name as its first parameter and 
returns a value.
-However, if you use a coderef then extension arguments are not supported.
+an arbitrary C<CODE> ref that when given a key name as its first parameter
+and returns a value and if given no arguments returns a list of all keys 
present.
 
 If you pass in a hashref or a coderef it is your responsibility as the caller
 to check the HTTP request method and pass in the correct set of arguments.
@@ -300,6 +292,8 @@ access it through a L<Net::OpenID::Consumer> instance.
 
 =head1 METHODS
 
+=over 4
+
 =item B<protocol_version>
 
 Currently returns 1 or 2, according as this is an OpenID 1.0/1.1 or an OpenID 
2.0 message.
@@ -312,3 +306,5 @@ Takes an extension namespace and returns true if the named 
extension is used in
 
 Takes an extension namespace and an optional parameter name, returns the 
parameter value,
 or if no parameter given, the parameter value.
+
+=back

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/libnet-openid-common-perl.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to