r63202 - in /branches/upstream/libplack-perl/current: ./ lib/ lib/Plack/ lib/Plack/App/ lib/Plack/Middleware/ lib/Plack/Server/ share/ t/Plack-Middleware/

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Sun Oct 3 14:14:11 UTC 2010


Author: jawnsy-guest
Date: Sun Oct  3 14:12:09 2010
New Revision: 63202

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=63202
Log:
[svn-upgrade] new version libplack-perl (0.9950)

Added:
    branches/upstream/libplack-perl/current/share/#foo
    branches/upstream/libplack-perl/current/t/Plack-Middleware/directory.t
Modified:
    branches/upstream/libplack-perl/current/Changes
    branches/upstream/libplack-perl/current/MANIFEST
    branches/upstream/libplack-perl/current/META.yml
    branches/upstream/libplack-perl/current/lib/Plack.pm
    branches/upstream/libplack-perl/current/lib/Plack/App/Directory.pm
    branches/upstream/libplack-perl/current/lib/Plack/Builder.pm
    branches/upstream/libplack-perl/current/lib/Plack/Middleware/JSONP.pm
    branches/upstream/libplack-perl/current/lib/Plack/Request.pm
    branches/upstream/libplack-perl/current/lib/Plack/Response.pm
    branches/upstream/libplack-perl/current/lib/Plack/Server/ServerSimple.pm
    branches/upstream/libplack-perl/current/lib/Plack/Util.pm
    branches/upstream/libplack-perl/current/t/Plack-Middleware/jsonp.t

Modified: branches/upstream/libplack-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/Changes?rev=63202&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/Changes (original)
+++ branches/upstream/libplack-perl/current/Changes Sun Oct  3 14:12:09 2010
@@ -1,6 +1,11 @@
 Revision history for Perl extension Plack
 
 Take a look at http://github.com/miyagawa/Plack/issues for the planned changes before 1.0 release.
+
+0.9950  Thu Sep 30 14:11:33 PDT 2010
+        - Fixed typos in middleware docs (miyagawa, theory, tokuhirom)
+        - App::Directory: fixed URL generation escape bug (chiba)
+        - Middleware::JSONP: support callback parameter name (franck)
 
 0.9949  Tue Sep 14 11:59:36 PDT 2010
         - Fixed FCGI handler docs

Modified: branches/upstream/libplack-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/MANIFEST?rev=63202&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/MANIFEST (original)
+++ branches/upstream/libplack-perl/current/MANIFEST Sun Oct  3 14:12:09 2010
@@ -133,6 +133,7 @@
 META.yml
 README
 scripts/plackup
+share/#foo
 share/baybridge.jpg
 share/face.jpg
 t/00_compile.t
@@ -175,6 +176,7 @@
 t/Plack-Middleware/conditional.t
 t/Plack-Middleware/conditionalget.t
 t/Plack-Middleware/content_length.t
+t/Plack-Middleware/directory.t
 t/Plack-Middleware/error_document.t
 t/Plack-Middleware/errors/404.html
 t/Plack-Middleware/errors/500.html

Modified: branches/upstream/libplack-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/META.yml?rev=63202&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/META.yml (original)
+++ branches/upstream/libplack-perl/current/META.yml Sun Oct  3 14:12:09 2010
@@ -38,4 +38,4 @@
 resources:
   license: http://dev.perl.org/licenses/
   repository: git://github.com/miyagawa/Plack.git
-version: 0.9949
+version: 0.9950

Modified: branches/upstream/libplack-perl/current/lib/Plack.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack.pm?rev=63202&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack.pm Sun Oct  3 14:12:09 2010
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use 5.008_001;
-our $VERSION = '0.9949';
+our $VERSION = '0.9950';
 $VERSION = eval $VERSION;
 
 1;

Modified: branches/upstream/libplack-perl/current/lib/Plack/App/Directory.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/App/Directory.pm?rev=63202&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/App/Directory.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/App/Directory.pm Sun Oct  3 14:12:09 2010
@@ -6,6 +6,7 @@
 use HTTP::Date;
 use Plack::MIME;
 use DirHandle;
+use URI::Escape;
 
 # Stolen from rack/directory.rb
 my $dir_file = "<tr><td class='name'><a href='%s'>%s</a></td><td class='size'>%s</td><td class='type'>%s</td><td class='mtime'>%s</td></tr>";
@@ -70,6 +71,8 @@
             $url      .= "/";
         }
 
+        $url = join '/', map {uri_escape($_)} split m{/}, $url;
+
         my $mime_type = $is_dir ? 'directory' : ( Plack::MIME->mime_type($file) || 'text/plain' );
         push @files, [ $url, $basename, $stat[7], $mime_type, HTTP::Date::time2str($stat[9]) ];
     }

Modified: branches/upstream/libplack-perl/current/lib/Plack/Builder.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Builder.pm?rev=63202&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Builder.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Builder.pm Sun Oct  3 14:12:09 2010
@@ -134,7 +134,7 @@
 middleware you're trying to use should use L<Plack::Middleware> as a
 base class to use this DSL, inspired by Rack::Builder.
 
-Whenever you call C<add> on any middleware, the middleware app is
+Whenever you call C<enable> on any middleware, the middleware app is
 pushed to the stack inside the builder, and then reversed when it
 actually creates a wrapped application handler, so:
 
@@ -149,7 +149,7 @@
   $app = Plack::Middleware::Bar->wrap($app, opt => "val");
   $app = Plack::Middleware::Foo->wrap($app);
 
-In other words, you're supposed to C<add> middleware from outer to inner.
+In other words, you're supposed to C<enable> middleware from outer to inner.
 
 =head1 INLINE MIDDLEWARE
 

Modified: branches/upstream/libplack-perl/current/lib/Plack/Middleware/JSONP.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Middleware/JSONP.pm?rev=63202&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Middleware/JSONP.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Middleware/JSONP.pm Sun Oct  3 14:12:09 2010
@@ -3,6 +3,8 @@
 use parent qw(Plack::Middleware);
 use Plack::Util;
 use URI::Escape ();
+
+use Plack::Util::Accessor qw/callback_key/;
 
 sub call {
     my($self, $env) = @_;
@@ -11,9 +13,9 @@
         my $res = shift;
         if (defined $res->[2] && ref $res->[2] eq 'ARRAY' && @{$res->[2]} == 1) {
             my $h = Plack::Util::headers($res->[1]);
+            my $callback_key = quotemeta($self->callback_key) || 'callback';
             if ($h->get('Content-Type') =~ m!/(?:json|javascript)! &&
-                $env->{QUERY_STRING} =~ /(?:^|&)callback=([^&]+)/) {
-                # TODO: support callback params other than 'callback'
+                $env->{QUERY_STRING} =~ /(?:^|&)$callback_key=([^&]+)/) {
                 my $cb = URI::Escape::uri_unescape($1);
                 if ($cb =~ /^[\w\.\[\]]+$/) {
                     my $jsonp = "$cb($res->[2][0])";
@@ -34,11 +36,16 @@
 
 Plack::Middleware::JSONP - Wraps JSON response in JSONP if callback parameter is specified
 
+=head1 SYNOPSIS
+
+    enable "JSONP", callback_key => 'jsonp';
+
 =head1 DESCRIPTION
 
 Plack::Middleware::JSONP wraps JSON response, which has Content-Type
 value either C<text/javascript> or C<application/json> as a JSONP
-response which is specified with the C<callback> query parameter.
+response which is specified with the C<callback> query parameter. The 
+name of the parameter can be set while enabling the middleware.
 
 This middleware only works with an application response with content
 body set as a single element array ref and doesn't touch the response

Modified: branches/upstream/libplack-perl/current/lib/Plack/Request.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Request.pm?rev=63202&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Request.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Request.pm Sun Oct  3 14:12:09 2010
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 use 5.008_001;
-our $VERSION = '0.9949';
+our $VERSION = '0.9950';
 $VERSION = eval $VERSION;
 
 use HTTP::Headers;

Modified: branches/upstream/libplack-perl/current/lib/Plack/Response.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Response.pm?rev=63202&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Response.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Response.pm Sun Oct  3 14:12:09 2010
@@ -1,7 +1,7 @@
 package Plack::Response;
 use strict;
 use warnings;
-our $VERSION = '0.9949';
+our $VERSION = '0.9950';
 $VERSION = eval $VERSION;
 
 use Plack::Util::Accessor qw(body status);

Modified: branches/upstream/libplack-perl/current/lib/Plack/Server/ServerSimple.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Server/ServerSimple.pm?rev=63202&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Server/ServerSimple.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Server/ServerSimple.pm Sun Oct  3 14:12:09 2010
@@ -1,6 +1,6 @@
 package Plack::Server::ServerSimple;
 use strict;
-our $VERSION = '0.9949';
+our $VERSION = '0.9950';
 $VERSION = eval $VERSION;
 
 use parent qw(Plack::Handler::HTTP::Server::Simple);

Modified: branches/upstream/libplack-perl/current/lib/Plack/Util.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Util.pm?rev=63202&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Util.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Util.pm Sun Oct  3 14:12:09 2010
@@ -449,7 +449,7 @@
 name as case insensitive.
 
   my $hdrs = [ 'Content-Type' => 'text/plain' ];
-  my $v = Plack::Util::header_get('content-type'); # 'text/plain'
+  my $v = Plack::Util::header_get($hdrs, 'content-type'); # 'text/plain'
 
 =item headers
 

Added: branches/upstream/libplack-perl/current/share/#foo
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/share/%23foo?rev=63202&op=file
==============================================================================
    (empty)

Added: branches/upstream/libplack-perl/current/t/Plack-Middleware/directory.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/t/Plack-Middleware/directory.t?rev=63202&op=file
==============================================================================
--- branches/upstream/libplack-perl/current/t/Plack-Middleware/directory.t (added)
+++ branches/upstream/libplack-perl/current/t/Plack-Middleware/directory.t Sun Oct  3 14:12:09 2010
@@ -1,0 +1,28 @@
+use strict;
+use warnings;
+use Test::More;
+use HTTP::Request::Common;
+use HTTP::Response;
+use Plack::Test;
+use Plack::App::Directory;
+
+my $handler = Plack::App::Directory->new({ root => 'share' });
+
+
+my %test = (
+    client => sub {
+        my $cb  = shift;
+
+        {
+            # URI-escape
+            my $res = $cb->(GET "http://localhost/");
+            my($ct, $charset) = $res->content_type;
+            ok $res->content =~ m{/%23foo};
+        }
+},
+    app => $handler,
+);
+
+test_psgi %test;
+
+done_testing;

Modified: branches/upstream/libplack-perl/current/t/Plack-Middleware/jsonp.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/t/Plack-Middleware/jsonp.t?rev=63202&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/t/Plack-Middleware/jsonp.t (original)
+++ branches/upstream/libplack-perl/current/t/Plack-Middleware/jsonp.t Sun Oct  3 14:12:09 2010
@@ -5,25 +5,41 @@
 
 my $json = '{"foo":"bar"}';
 
-my @app = (
-    sub {
-        return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ];
+my @tests = (
+    {
+        callback_key => 'json.p',
+        app          => sub {
+            return [ 200, [ 'Content-Type' => 'application/json' ], [$json] ];
+        },
     },
-    sub {
-        return sub {
-            my $respond = shift;
-            $respond->(
-                [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ]
-            );
-        };
-    },
+    {
+        app => sub {
+            return sub {
+                my $respond = shift;
+                $respond->(
+                    [ 200, [ 'Content-Type' => 'application/json' ], [$json] ]
+                );
+            };
+        },
+    }
 );
 
-for my $app ( @app ) {
-    $app = builder {
-        enable "Plack::Middleware::JSONP";
-        $app;
-    };
+for my $test ( @tests ) {
+    my $app = $test->{app};
+
+    if ( exists $test->{callback_key} ) {
+        $app = builder {
+            enable "Plack::Middleware::JSONP", callback_key => $test->{callback_key};
+            $app;
+        };
+    }
+    else {
+        $app = builder {
+            enable "Plack::Middleware::JSONP";
+            $app;
+        };
+    }
+    my $callback_key = $test->{callback_key} || 'callback';
 
     test_psgi app => $app, client => sub {
         my $cb = shift;
@@ -31,7 +47,7 @@
         my $res = $cb->(HTTP::Request->new(GET => 'http://localhost/'));
         is $res->content_type, 'application/json';
         is $res->content, $json;
-        $res = $cb->(HTTP::Request->new(GET => 'http://localhost/?callback=foo'));
+        $res = $cb->(HTTP::Request->new(GET => 'http://localhost/?'.$callback_key.'=foo'));
         is $res->content_type, 'text/javascript';
         is $res->content, "foo($json)";
     };




More information about the Pkg-perl-cvs-commits mailing list