r74694 - in /branches/upstream/libplack-perl/current: ./ eg/dot-psgi/ lib/ lib/Plack/ lib/Plack/Handler/ lib/Plack/Middleware/ lib/Plack/Server/ t/Plack-Loader/ t/Plack-Middleware/
ghedo-guest at users.alioth.debian.org
ghedo-guest at users.alioth.debian.org
Wed May 18 17:44:09 UTC 2011
Author: ghedo-guest
Date: Wed May 18 17:43:51 2011
New Revision: 74694
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=74694
Log:
[svn-upgrade] new version libplack-perl (0.9979)
Added:
branches/upstream/libplack-perl/current/eg/dot-psgi/nonblock-hello.psgi
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/Handler/Apache1.pm
branches/upstream/libplack-perl/current/lib/Plack/Handler/CGI.pm
branches/upstream/libplack-perl/current/lib/Plack/Middleware/AccessLog.pm
branches/upstream/libplack-perl/current/lib/Plack/Middleware/Lint.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-Loader/auto.t
branches/upstream/libplack-perl/current/t/Plack-Middleware/conditionalget_writer.t
branches/upstream/libplack-perl/current/t/Plack-Middleware/lint.t
Modified: branches/upstream/libplack-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/Changes?rev=74694&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/Changes (original)
+++ branches/upstream/libplack-perl/current/Changes Wed May 18 17:43:51 2011
@@ -1,6 +1,18 @@
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.9979 Tue May 17 09:54:03 PDT 2011
+ [BUG FIXES]
+ - Fixed Middleware::AccessLog's default %t format to match Apache's format
+ - Fixed a warning in Apache1 handler where PATH_INFO doesn't exist #204
+ - Fixed a bad test relying on new Test::More versions
+
+ [IMPROVEMENTS]
+ - Fixed Lint to accept bare in-memory filehandle per http://stackoverflow.com/questions/6011793/
+ - Added setup_env() to Plack::Handler::CGI (markstos)
+ - Added a non-blocking Hello World example in eg/dot-psgi
+ - Doc cleanup
0.9978 Wed May 4 11:29:12 PDT 2011
[TEST FIXES]
Modified: branches/upstream/libplack-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/MANIFEST?rev=74694&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/MANIFEST (original)
+++ branches/upstream/libplack-perl/current/MANIFEST Wed May 18 17:43:51 2011
@@ -20,6 +20,7 @@
eg/dot-psgi/frameworks/Squatting.psgi
eg/dot-psgi/Hello.psgi
eg/dot-psgi/image.psgi
+eg/dot-psgi/nonblock-hello.psgi
eg/dot-psgi/plack-req.psgi
eg/dot-psgi/runnable.psgi
eg/dot-psgi/slowapp.psgi
Modified: branches/upstream/libplack-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/META.yml?rev=74694&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/META.yml (original)
+++ branches/upstream/libplack-perl/current/META.yml Wed May 18 17:43:51 2011
@@ -40,4 +40,4 @@
homepage: http://plackperl.org
license: http://dev.perl.org/licenses/
repository: git://github.com/miyagawa/Plack.git
-version: 0.9978
+version: 0.9979
Added: branches/upstream/libplack-perl/current/eg/dot-psgi/nonblock-hello.psgi
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/eg/dot-psgi/nonblock-hello.psgi?rev=74694&op=file
==============================================================================
--- branches/upstream/libplack-perl/current/eg/dot-psgi/nonblock-hello.psgi (added)
+++ branches/upstream/libplack-perl/current/eg/dot-psgi/nonblock-hello.psgi Wed May 18 17:43:51 2011
@@ -1,0 +1,20 @@
+use AnyEvent;
+
+my $app = sub {
+ my $env = shift;
+
+ warn "This app needs a server that supports psgi.streaming and psgi.nonblocking"
+ unless $env->{'psgi.streaming'} && $env->{'psgi.nonblocking'};
+
+ my $cv = AE::cv;
+ return sub {
+ my $respond = shift;
+ my $w = $respond->([ 200, ['Content-Type' => 'text/plain'] ]);
+ $w->write("Hello\n");
+ my $t; $t = AE::timer 2, 0, sub {
+ undef $t;
+ $w->write("World\n");
+ $w->close;
+ };
+ };
+};
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=74694&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack.pm Wed May 18 17:43:51 2011
@@ -3,7 +3,7 @@
use strict;
use warnings;
use 5.008_001;
-our $VERSION = '0.9978';
+our $VERSION = '0.9979';
$VERSION = eval $VERSION;
1;
Modified: branches/upstream/libplack-perl/current/lib/Plack/Handler/Apache1.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Handler/Apache1.pm?rev=74694&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Handler/Apache1.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Handler/Apache1.pm Wed May 18 17:43:51 2011
@@ -54,7 +54,7 @@
$env->{HTTP_AUTHORIZATION} = $HTTP_AUTHORIZATION;
}
- my $vpath = $env->{SCRIPT_NAME} . $env->{PATH_INFO};
+ my $vpath = $env->{SCRIPT_NAME} . ($env->{PATH_INFO} || '');
my $location = $r->location || "/";
$location =~ s{/$}{};
Modified: branches/upstream/libplack-perl/current/lib/Plack/Handler/CGI.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Handler/CGI.pm?rev=74694&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Handler/CGI.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Handler/CGI.pm Wed May 18 17:43:51 2011
@@ -64,6 +64,27 @@
sub run {
my ($self, $app) = @_;
+ my $env = $self->setup_env();
+
+ my $res = $app->($env);
+ if (ref $res eq 'ARRAY') {
+ $self->_handle_response($res);
+ }
+ elsif (ref $res eq 'CODE') {
+ $res->(sub {
+ $self->_handle_response($_[0]);
+ });
+ }
+ else {
+ die "Bad response $res";
+ }
+}
+
+sub setup_env {
+ my ( $self, $override_env ) = @_;
+
+ $override_env ||= {};
+
my $env = {
%ENV,
'psgi.version' => [ 1, 1 ],
@@ -75,6 +96,7 @@
'psgi.run_once' => 1,
'psgi.streaming' => 1,
'psgi.nonblocking' => 1,
+ %{ $override_env },
};
delete $env->{HTTP_CONTENT_TYPE};
@@ -90,19 +112,10 @@
$env->{PATH_INFO} = '/' . $env->{PATH_INFO};
}
- my $res = $app->($env);
- if (ref $res eq 'ARRAY') {
- $self->_handle_response($res);
- }
- elsif (ref $res eq 'CODE') {
- $res->(sub {
- $self->_handle_response($_[0]);
- });
- }
- else {
- die "Bad response $res";
- }
+ return $env;
}
+
+
sub _handle_response {
my ($self, $res) = @_;
@@ -185,6 +198,16 @@
This is a handler module to run any PSGI application as a CGI script.
+=head1 UTILITY METHODS
+
+=head2 setup_env()
+
+ my $env = Plack::Handler::CGI->setup_env();
+ my $env = Plack::Handler::CGI->setup_env(\%override_env);
+
+Sets up the PSGI environment hash for a CGI request from C<< %ENV >>> and returns it.
+You can can provide a hashref of key/value pairs to override the defaults if you would like.
+
=head1 SEE ALSO
L<Plack>
Modified: branches/upstream/libplack-perl/current/lib/Plack/Middleware/AccessLog.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Middleware/AccessLog.pm?rev=74694&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Middleware/AccessLog.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Middleware/AccessLog.pm Wed May 18 17:43:51 2011
@@ -64,7 +64,7 @@
h => sub { $env->{REMOTE_ADDR} || '-' },
l => sub { '-' },
u => sub { $env->{REMOTE_USER} || '-' },
- t => sub { "[" . $strftime->("%d/%b/%Y %H:%M:%S", localtime) . "]" },
+ t => sub { "[" . $strftime->("%d/%b/%Y:%H:%M:%S %z", localtime) . "]" },
r => sub { _safe($env->{REQUEST_METHOD}) . " " . _safe($env->{REQUEST_URI}) .
" " . $env->{SERVER_PROTOCOL} },
s => sub { $status },
Modified: branches/upstream/libplack-perl/current/lib/Plack/Middleware/Lint.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Middleware/Lint.pm?rev=74694&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Middleware/Lint.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Middleware/Lint.pm Wed May 18 17:43:51 2011
@@ -83,6 +83,14 @@
}
}
+sub is_possibly_fh {
+ my $fh = shift;
+
+ ref $fh eq 'GLOB' &&
+ *{$fh}{IO} &&
+ *{$fh}{IO}->can('getline');
+}
+
sub validate_res {
my ($self, $res, $streaming) = @_;
@@ -112,6 +120,7 @@
unless (@$res == 2 ||
ref $res->[2] eq 'ARRAY' ||
Plack::Util::is_real_fh($res->[2]) ||
+ is_possibly_fh($res->[2]) ||
(blessed($res->[2]) && $res->[2]->can('getline'))) {
$croak->('body should be an array ref or filehandle');
}
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=74694&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Request.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Request.pm Wed May 18 17:43:51 2011
@@ -2,7 +2,7 @@
use strict;
use warnings;
use 5.008_001;
-our $VERSION = '0.9978';
+our $VERSION = '0.9979';
$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=74694&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Response.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Response.pm Wed May 18 17:43:51 2011
@@ -1,7 +1,7 @@
package Plack::Response;
use strict;
use warnings;
-our $VERSION = '0.9978';
+our $VERSION = '0.9979';
$VERSION = eval $VERSION;
use Plack::Util::Accessor qw(body status);
@@ -271,6 +271,13 @@
expires => time + 24 * 60 * 60,
};
+=item finalize
+
+ $res->finalize;
+
+Returns the status code, headers, and body of this response as a PSGI
+response array reference.
+
=back
=head1 AUTHOR
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=74694&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Server/ServerSimple.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Server/ServerSimple.pm Wed May 18 17:43:51 2011
@@ -1,6 +1,6 @@
package Plack::Server::ServerSimple;
use strict;
-our $VERSION = '0.9978';
+our $VERSION = '0.9979';
$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=74694&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Util.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Util.pm Wed May 18 17:43:51 2011
@@ -259,7 +259,7 @@
sub inline_object {
my %args = @_;
- bless {%args}, 'Plack::Util::Prototype';
+ bless \%args, 'Plack::Util::Prototype';
}
sub response_cb {
Modified: branches/upstream/libplack-perl/current/t/Plack-Loader/auto.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/t/Plack-Loader/auto.t?rev=74694&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/t/Plack-Loader/auto.t (original)
+++ branches/upstream/libplack-perl/current/t/Plack-Loader/auto.t Wed May 18 17:43:51 2011
@@ -1,4 +1,5 @@
use strict;
+use warnings;
use Test::More;
use Plack::Loader;
@@ -12,6 +13,7 @@
$INC{"Plack/Handler/Twiggy.pm"} = __FILE__;
sub Plack::Handler::Twiggy::new { bless {}, shift }
+no warnings 'redefine';
local *Plack::Loader::env = sub { return {} };
eval {
Modified: branches/upstream/libplack-perl/current/t/Plack-Middleware/conditionalget_writer.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/t/Plack-Middleware/conditionalget_writer.t?rev=74694&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/t/Plack-Middleware/conditionalget_writer.t (original)
+++ branches/upstream/libplack-perl/current/t/Plack-Middleware/conditionalget_writer.t Wed May 18 17:43:51 2011
@@ -25,21 +25,17 @@
test_psgi $handler, sub {
my $cb = shift;
- subtest 'streaming' => sub {
- my $res = $cb->( GET "http://localhost/streaming-klingklangklong" );
- is $res->code, 200, 'Response HTTP status';
- is $res->content, 'klingklangklong', 'Response content';
- };
+ my $res = $cb->( GET "http://localhost/streaming-klingklangklong" );
+ is $res->code, 200, 'Response HTTP status';
+ is $res->content, 'klingklangklong', 'Response content';
- subtest 'streaming not modified' => sub {
- # the middleware does not support streaming interface but make it at least not die
- my $res = $cb->( GET
- "http://localhost/streaming-klingklangklong",
- 'If-None-Match' => 'DEADBEEF'
- );
- is $res->code, 200, 'Response HTTP status';
- is $res->content, 'klingklangklong', 'Response content';
- };
+ # the middleware does not support streaming interface but make it at least not die
+ $res = $cb->( GET
+ "http://localhost/streaming-klingklangklong",
+ 'If-None-Match' => 'DEADBEEF'
+ );
+ is $res->code, 200, 'Response HTTP status';
+ is $res->content, 'klingklangklong', 'Response content';
};
done_testing;
Modified: branches/upstream/libplack-perl/current/t/Plack-Middleware/lint.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/t/Plack-Middleware/lint.t?rev=74694&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/t/Plack-Middleware/lint.t (original)
+++ branches/upstream/libplack-perl/current/t/Plack-Middleware/lint.t Wed May 18 17:43:51 2011
@@ -17,6 +17,13 @@
sub { return sub { shift->([ 200, [], undef ]) } },
);
+my @good = map { Plack::Middleware::Lint->wrap($_) } (
+ sub {
+ open my $io, "<", \"foo";
+ return [ 200, [ "Content-Type", "text/plain" ], $io ];
+ },
+);
+
for my $app (@bad) {
test_psgi $app, sub {
my $cb = shift;
@@ -25,4 +32,12 @@
};
}
+for my $app (@good) {
+ test_psgi $app, sub {
+ my $cb = shift;
+ my $res = $cb->(GET "/");
+ is $res->code, 200, $res->content;
+ };
+}
+
done_testing;
More information about the Pkg-perl-cvs-commits
mailing list