r64874 - in /branches/upstream/libplack-perl/current: ./ benchmarks/ lib/ lib/Plack/ lib/Plack/App/ lib/Plack/Middleware/ lib/Plack/Server/ t/Plack-Builder/ t/Plack-Middleware/ t/Plack-Response/
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Sat Nov 13 22:33:58 UTC 2010
Author: gregoa
Date: Sat Nov 13 22:33:46 2010
New Revision: 64874
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=64874
Log:
[svn-upgrade] new version libplack-perl (0.9951)
Added:
branches/upstream/libplack-perl/current/t/Plack-Builder/oo_interface.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/benchmarks/ab.pl
branches/upstream/libplack-perl/current/lib/Plack.pm
branches/upstream/libplack-perl/current/lib/Plack/App/FCGIDispatcher.pm
branches/upstream/libplack-perl/current/lib/Plack/Builder.pm
branches/upstream/libplack-perl/current/lib/Plack/Middleware/ErrorDocument.pm
branches/upstream/libplack-perl/current/lib/Plack/Middleware/HTTPExceptions.pm
branches/upstream/libplack-perl/current/lib/Plack/Middleware/JSONP.pm
branches/upstream/libplack-perl/current/lib/Plack/Middleware/StackTrace.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/t/Plack-Middleware/stacktrace.t
branches/upstream/libplack-perl/current/t/Plack-Response/body.t
Modified: branches/upstream/libplack-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/Changes?rev=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/Changes (original)
+++ branches/upstream/libplack-perl/current/Changes Sat Nov 13 22:33:46 2010
@@ -1,6 +1,14 @@
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.9951 Mon Oct 25 13:50:33 PDT 2010
+ - Added Feersum to the benchmark script (stash)
+ - Lint: fixed the body handle check to see if the file has getline() method (tokuhirom)
+ - StackTrace: store the stacktrace in $env->{'plack.stacktrace.text'} and $env->{'plack.stacktrace.html'} (theory)
+ - Added ->mount method to the Plack::Builder OO interface (franckcuny)
+ - HTTPExceptions: Don't set an invalid Content-Length when the exception is not an object (ask)
+ - ErrorDocument: Fixed wrong Content-Length header be set (ask)
0.9950 Thu Sep 30 14:11:33 PDT 2010
- Fixed typos in middleware docs (miyagawa, theory, tokuhirom)
Modified: branches/upstream/libplack-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/MANIFEST?rev=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/MANIFEST (original)
+++ branches/upstream/libplack-perl/current/MANIFEST Sat Nov 13 22:33:46 2010
@@ -140,6 +140,7 @@
t/FCGIUtils.pm
t/HTTP-Message-PSGI/utf8_req.t
t/Plack-Builder/mount.t
+t/Plack-Builder/oo_interface.t
t/Plack-Handler/apache1.t
t/Plack-Handler/apache2-registry.t
t/Plack-Handler/apache2.t
Modified: branches/upstream/libplack-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/META.yml?rev=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/META.yml (original)
+++ branches/upstream/libplack-perl/current/META.yml Sat Nov 13 22:33:46 2010
@@ -38,4 +38,4 @@
resources:
license: http://dev.perl.org/licenses/
repository: git://github.com/miyagawa/Plack.git
-version: 0.9950
+version: 0.9951
Modified: branches/upstream/libplack-perl/current/benchmarks/ab.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/benchmarks/ab.pl?rev=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/benchmarks/ab.pl (original)
+++ branches/upstream/libplack-perl/current/benchmarks/ab.pl Sat Nov 13 22:33:46 2010
@@ -11,7 +11,7 @@
use String::ShellQuote;
my $app = 'eg/dot-psgi/Hello.psgi';
-my $ab = 'ab -t 1 -c 10 -k';
+my $ab = 'ab -t 1 -c 10 -k -q';
my $url = 'http://127.0.0.1/';
my @try = (
@@ -24,6 +24,7 @@
[ '+POE::Component::Server::PSGI' ],
[ 'Starlet', ' (workers=10)', max_workers => 10 ],
[ 'Starman', ' (workers=10)', workers => 10 ],
+ [ 'Feersum' ],
);
my @backends;
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=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack.pm Sat Nov 13 22:33:46 2010
@@ -3,7 +3,7 @@
use strict;
use warnings;
use 5.008_001;
-our $VERSION = '0.9950';
+our $VERSION = '0.9951';
$VERSION = eval $VERSION;
1;
Modified: branches/upstream/libplack-perl/current/lib/Plack/App/FCGIDispatcher.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/App/FCGIDispatcher.pm?rev=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/App/FCGIDispatcher.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/App/FCGIDispatcher.pm Sat Nov 13 22:33:46 2010
@@ -94,8 +94,16 @@
=head1 DESCRIPTION
-Plack::App::FCGIDispatcher is not really a middleware but it's
-a PSGI application to dispatch requests to external FCGI servers.
+Plack::App::FCGIDispatcher is a PSGI application to dispatch requests
+to external FastCGI servers listening on TCP or UNIX sockets.
+
+Since external FastCGI servers can be written in any language such as
+Ruby or PHP, this could be useful to route requests to Rails
+applications for instance from your Plack-based web server, or apply
+one of Plack middleware to PHP applications.
+
+See also L<Plack::App::Proxy> which uses HTTP instead of FastCGI and
+has more configuration options.
=head1 CONFIGURATION
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=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Builder.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Builder.pm Sat Nov 13 22:33:46 2010
@@ -38,6 +38,17 @@
# do you want remove_middleware() etc.?
+sub _mount {
+ my ($self, $location, $app) = @_;
+
+ if (!$self->{_urlmap}) {
+ $self->{_urlmap} = Plack::App::URLMap->new;
+ }
+
+ $self->{_urlmap}->map($location => $app);
+ $self->{_urlmap};
+}
+
sub to_app {
my($self, $app) = @_;
@@ -56,7 +67,15 @@
sub add { Carp::carp("add is deprecated. Use 'enable'"); $_add->(@_) }
sub enable { $_add->(@_) }
sub enable_if(&$@) { $_add_if->(@_) }
-sub mount { $_mount->(@_) }
+
+sub mount {
+ my $self = shift;
+ if (Scalar::Util::blessed($self)) {
+ $self->_mount(@_);
+ }else{
+ $_mount->($self, @_);
+ }
+}
sub builder(&) {
my $block = shift;
@@ -127,6 +146,13 @@
mount "http://example.com/" => builder { $app3 };
};
+ # using OO interface
+
+ my $builder = Plack::Builder->new();
+ $builder->add_middleware('Foo', opt => 1);
+ $app = $builder->mount('/app' => $app);
+ $app = $builder->to_app($app);
+
=head1 DESCRIPTION
Plack::Builder gives you a quick domain specific language (DSL) to
@@ -172,8 +198,7 @@
my $mw = sub {
my $app = shift;
- sub { my $env = shift; $app->($env) };
- };
+ sub { my $env = shift; $app->($env) };
};
$app = $mw->($app);
Modified: branches/upstream/libplack-perl/current/lib/Plack/Middleware/ErrorDocument.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Middleware/ErrorDocument.pm?rev=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Middleware/ErrorDocument.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Middleware/ErrorDocument.pm Sat Nov 13 22:33:46 2010
@@ -45,6 +45,7 @@
open my $fh, "<", $path or die "$path: $!";
$r->[2] = $fh;
my $h = Plack::Util::headers($r->[1]);
+ $h->remove('Content-Length');
$h->set('Content-Type', Plack::MIME->mime_type($path));
}
});
@@ -99,6 +100,8 @@
404 and 403 pages using a sub request so your application can do some
logic there like logging or doing suggestions.
+When using a subrequest, the subrequest should return a regular '200' response.
+
=back
=head1 AUTHOR
Modified: branches/upstream/libplack-perl/current/lib/Plack/Middleware/HTTPExceptions.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Middleware/HTTPExceptions.pm?rev=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Middleware/HTTPExceptions.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Middleware/HTTPExceptions.pm Sat Nov 13 22:33:46 2010
@@ -54,6 +54,8 @@
die $e; # rethrow
}
+ $message ||= HTTP::Status::status_message($code);
+
my @headers = (
'Content-Type' => 'text/plain',
'Content-Length' => length($message),
@@ -62,8 +64,6 @@
if ($code =~ /^3/ && (my $loc = eval { $e->location })) {
push(@headers, Location => $loc);
}
-
- $message ||= HTTP::Status::status_message($code);
return [ $code, \@headers, [ $message ] ];
}
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=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Middleware/JSONP.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Middleware/JSONP.pm Sat Nov 13 22:33:46 2010
@@ -6,6 +6,13 @@
use Plack::Util::Accessor qw/callback_key/;
+sub prepare_app {
+ my $self = shift;
+ unless (defined $self->callback_key) {
+ $self->callback_key('callback');
+ }
+}
+
sub call {
my($self, $env) = @_;
my $res = $self->app->($env);
@@ -13,7 +20,7 @@
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';
+ my $callback_key = $self->callback_key;
if ($h->get('Content-Type') =~ m!/(?:json|javascript)! &&
$env->{QUERY_STRING} =~ /(?:^|&)$callback_key=([^&]+)/) {
my $cb = URI::Escape::uri_unescape($1);
Modified: branches/upstream/libplack-perl/current/lib/Plack/Middleware/StackTrace.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Middleware/StackTrace.pm?rev=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Middleware/StackTrace.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Middleware/StackTrace.pm Sat Nov 13 22:33:46 2010
@@ -28,9 +28,12 @@
if ($trace && ($caught || ($self->force && ref $res eq 'ARRAY' && $res->[0] == 500)) ) {
my $text = trace_as_string($trace);
+ my $html = $trace->as_html;
+ $env->{'plack.stacktrace.text'} = $text;
+ $env->{'plack.stacktrace.html'} = $html;
$env->{'psgi.errors'}->print($text) unless $self->no_print_errors;
if (($env->{HTTP_ACCEPT} || '*/*') =~ /html/) {
- $res = [500, ['Content-Type' => 'text/html; charset=utf-8'], [ utf8_safe($trace->as_html) ]];
+ $res = [500, ['Content-Type' => 'text/html; charset=utf-8'], [ utf8_safe($html) ]];
} else {
$res = [500, ['Content-Type' => 'text/plain; charset=utf-8'], [ utf8_safe($text) ]];
}
@@ -90,7 +93,10 @@
=head1 DESCRIPTION
This middleware catches exceptions (run-time errors) happening in your
-application and displays nice stack trace screen.
+application and displays nice stack trace screen. The stack trace is
+also stored in the environment as a plaintext and HTML under the key
+C<plack.stacktrace.text> and C<plack.stacktrace.html> respectively, so
+that middleware futher up the stack can reference it.
This middleware is enabled by default when you run L<plackup> in the
default I<development> mode.
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=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Request.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Request.pm Sat Nov 13 22:33:46 2010
@@ -2,7 +2,7 @@
use strict;
use warnings;
use 5.008_001;
-our $VERSION = '0.9950';
+our $VERSION = '0.9951';
$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=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Response.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Response.pm Sat Nov 13 22:33:46 2010
@@ -1,7 +1,7 @@
package Plack::Response;
use strict;
use warnings;
-our $VERSION = '0.9950';
+our $VERSION = '0.9951';
$VERSION = eval $VERSION;
use Plack::Util::Accessor qw(body status);
@@ -103,7 +103,7 @@
my $self = shift;
my $body = $self->body;
$body = [] unless defined $body;
- if (!ref $body or Scalar::Util::blessed($body) && overload::Method($body, q(""))) {
+ if (!ref $body or Scalar::Util::blessed($body) && overload::Method($body, q("")) && !$body->can('getline')) {
return [ $body ];
} else {
return $body;
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=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Server/ServerSimple.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Server/ServerSimple.pm Sat Nov 13 22:33:46 2010
@@ -1,6 +1,6 @@
package Plack::Server::ServerSimple;
use strict;
-our $VERSION = '0.9950';
+our $VERSION = '0.9951';
$VERSION = eval $VERSION;
use parent qw(Plack::Handler::HTTP::Server::Simple);
Added: branches/upstream/libplack-perl/current/t/Plack-Builder/oo_interface.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/t/Plack-Builder/oo_interface.t?rev=64874&op=file
==============================================================================
--- branches/upstream/libplack-perl/current/t/Plack-Builder/oo_interface.t (added)
+++ branches/upstream/libplack-perl/current/t/Plack-Builder/oo_interface.t Sat Nov 13 22:33:46 2010
@@ -1,0 +1,28 @@
+use strict;
+use warnings;
+use Test::More;
+use Plack::Builder;
+use HTTP::Request::Common;
+use Plack::Test;
+
+plan tests => 5;
+
+my $app = sub {
+ [200, ['Content-Type', 'text/plain'], ['ok']]
+};
+
+ok my $builder = Plack::Builder->new();
+$builder->add_middleware('Runtime');
+$app = $builder->mount('/app/foo/bar' => $app);
+$builder->add_middleware('XFramework', framework => 'Plack::Builder');
+$app = $builder->to_app($app);
+ok $app;
+
+test_psgi $app, sub {
+ my $cb = shift;
+
+ my $res = $cb->(GET "/app/foo/bar");
+ ok $res->header('X-Runtime');
+ is $res->header('X-Framework'), 'Plack::Builder';
+ is $res->content, "ok";
+};
Modified: branches/upstream/libplack-perl/current/t/Plack-Middleware/stacktrace.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/t/Plack-Middleware/stacktrace.t?rev=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/t/Plack-Middleware/stacktrace.t (original)
+++ branches/upstream/libplack-perl/current/t/Plack-Middleware/stacktrace.t Sat Nov 13 22:33:46 2010
@@ -5,7 +5,13 @@
use Plack::Test;
use HTTP::Request::Common;
-my $app = Plack::Middleware::StackTrace->wrap(sub { die "orz" }, no_print_errors => 1);
+my $traceapp = Plack::Middleware::StackTrace->wrap(sub { die "orz" }, no_print_errors => 1);
+my $app = sub {
+ my $env = shift;
+ my $ret = $traceapp->($env);
+ like $env->{'plack.stacktrace.text'}, qr/orz/;
+ return $ret;
+};
test_psgi $app, sub {
my $cb = shift;
Modified: branches/upstream/libplack-perl/current/t/Plack-Response/body.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/t/Plack-Response/body.t?rev=64874&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/t/Plack-Response/body.t (original)
+++ branches/upstream/libplack-perl/current/t/Plack-Response/body.t Sat Nov 13 22:33:46 2010
@@ -4,6 +4,7 @@
use Test::More;
use Plack::Response;
use URI;
+use File::Temp;
sub r($) {
my $res = Plack::Response->new(200);
@@ -30,5 +31,10 @@
is_deeply r $uri, [ $uri ];
}
+{
+ my $tmp = File::Temp->new("baz"); # File::Temp has stringify method, but it is-a IO::Handle.
+ is_deeply r $tmp, $tmp;
+}
+
done_testing;
More information about the Pkg-perl-cvs-commits
mailing list