r75225 - in /trunk/libplack-perl: ./ debian/ eg/dot-psgi/ lib/ lib/HTTP/Server/ lib/Plack/ lib/Plack/App/ lib/Plack/HTTPParser/ lib/Plack/Loader/ lib/Plack/Middleware/ lib/Plack/Server/ lib/Plack/Test/ scripts/ t/ t/Plack-HTTPParser-PP/ t/Plack-Handler/
ghedo-guest at users.alioth.debian.org
ghedo-guest at users.alioth.debian.org
Tue Jun 7 10:01:22 UTC 2011
Author: ghedo-guest
Date: Tue Jun 7 10:01:13 2011
New Revision: 75225
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=75225
Log:
* New upstream release
* Add libhttp-message-perl to (Build-)Depends(-Indep)
Removed:
trunk/libplack-perl/lib/Plack/App/FCGIDispatcher.pm
trunk/libplack-perl/t/Plack-Handler/fcgi_client.t
Modified:
trunk/libplack-perl/Changes
trunk/libplack-perl/MANIFEST
trunk/libplack-perl/META.yml
trunk/libplack-perl/Makefile.PL
trunk/libplack-perl/debian/changelog
trunk/libplack-perl/debian/control
trunk/libplack-perl/eg/dot-psgi/static.psgi
trunk/libplack-perl/lib/HTTP/Server/PSGI.pm
trunk/libplack-perl/lib/Plack.pm
trunk/libplack-perl/lib/Plack/HTTPParser.pm
trunk/libplack-perl/lib/Plack/HTTPParser/PP.pm
trunk/libplack-perl/lib/Plack/Loader.pm
trunk/libplack-perl/lib/Plack/Loader/Restarter.pm
trunk/libplack-perl/lib/Plack/Middleware/AccessLog.pm
trunk/libplack-perl/lib/Plack/Middleware/ConditionalGET.pm
trunk/libplack-perl/lib/Plack/Request.pm
trunk/libplack-perl/lib/Plack/Response.pm
trunk/libplack-perl/lib/Plack/Server/ServerSimple.pm
trunk/libplack-perl/lib/Plack/Test/Suite.pm
trunk/libplack-perl/scripts/plackup
trunk/libplack-perl/t/FCGIUtils.pm
trunk/libplack-perl/t/Plack-HTTPParser-PP/simple.t
Modified: trunk/libplack-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/Changes?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/Changes (original)
+++ trunk/libplack-perl/Changes Tue Jun 7 10:01:13 2011
@@ -1,6 +1,20 @@
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.9980 Mon Jun 6 20:24:25 PDT 2011
+ [BUG FIXES]
+ - Fixed a bug where restarting loader doesn't terminate children (#209)
+ - Strip URI fragments off of PATH_INFO and QUERY_STRING (#213)
+
+ [IMPROVEMENTS]
+ - Documented -r vs auto server detection caveat
+ - Documented a default AccessLog format (ask)
+ - Support %V in AccessLog formats (ask)
+ - Document PLACK_HTTP_PARSER_PP (melo)
+
+ [NEW FEATURES]
+ - Added experimental IPv6 and SSL support for the built-in HTTP::Server::PSGI
0.9979 Tue May 17 09:54:03 PDT 2011
[BUG FIXES]
Modified: trunk/libplack-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/MANIFEST?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/MANIFEST (original)
+++ trunk/libplack-perl/MANIFEST Tue Jun 7 10:01:13 2011
@@ -51,7 +51,6 @@
lib/Plack/App/Cascade.pm
lib/Plack/App/CGIBin.pm
lib/Plack/App/Directory.pm
-lib/Plack/App/FCGIDispatcher.pm
lib/Plack/App/File.pm
lib/Plack/App/PSGIBin.pm
lib/Plack/App/URLMap.pm
@@ -150,7 +149,6 @@
t/Plack-Handler/apache2.t
t/Plack-Handler/cgi.t
t/Plack-Handler/fcgi.t
-t/Plack-Handler/fcgi_client.t
t/Plack-Handler/http_server_simple.t
t/Plack-Handler/output_encoding.t
t/Plack-Handler/standalone.t
Modified: trunk/libplack-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/META.yml?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/META.yml (original)
+++ trunk/libplack-perl/META.yml Tue Jun 7 10:01:13 2011
@@ -27,8 +27,9 @@
File::ShareDir: 1.00
Filesys::Notify::Simple: 0
HTTP::Body: 1.06
+ HTTP::Message: 5.814
Hash::MultiValue: 0.05
- LWP: 5.814
+ LWP::UserAgent: 5.814
Pod::Usage: 0
Test::TCP: 0.11
Try::Tiny: 0
@@ -40,4 +41,4 @@
homepage: http://plackperl.org
license: http://dev.perl.org/licenses/
repository: git://github.com/miyagawa/Plack.git
-version: 0.9979
+version: 0.9980
Modified: trunk/libplack-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/Makefile.PL?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/Makefile.PL (original)
+++ trunk/libplack-perl/Makefile.PL Tue Jun 7 10:01:13 2011
@@ -9,8 +9,9 @@
all_from 'lib/Plack.pm';
readme_from 'lib/Plack.pm';
-requires 'LWP', 5.814; # HTTP::Status, HTTP::Headers and HTTP::Request
-requires 'URI', 1.36; # URI::Escape
+requires 'LWP::UserAgent', 5.814; # Plack::Test
+requires 'HTTP::Message', 5.814;
+requires 'URI', 1.36;
requires 'Pod::Usage'; # plackup
requires 'File::ShareDir', '1.00'; # Plack::Test::Suite
requires 'Try::Tiny';
Modified: trunk/libplack-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/debian/changelog?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/debian/changelog (original)
+++ trunk/libplack-perl/debian/changelog Tue Jun 7 10:01:13 2011
@@ -1,3 +1,10 @@
+libplack-perl (0.9980-1) UNRELEASED; urgency=low
+
+ * New upstream release
+ * Add libhttp-message-perl to (Build-)Depends(-Indep)
+
+ -- Alessandro Ghedini <al3xbio at gmail.com> Tue, 07 Jun 2011 11:53:55 +0200
+
libplack-perl (0.9979-1) unstable; urgency=low
[ Alessandro Ghedini ]
Modified: trunk/libplack-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/debian/control?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/debian/control (original)
+++ trunk/libplack-perl/debian/control Tue Jun 7 10:01:13 2011
@@ -13,6 +13,7 @@
libfilesys-notify-simple-perl,
libhash-multivalue-perl,
libhttp-body-perl (>= 1.06),
+ libhttp-message-perl,
libhttp-request-ascgi-perl,
libhttp-server-simple-psgi-perl,
libio-handle-util-perl,
@@ -47,6 +48,7 @@
libfilesys-notify-simple-perl,
libhash-multivalue-perl,
libhttp-body-perl (>= 1.06),
+ libhttp-message-perl,
libmodule-refresh-perl,
libtest-tcp-perl,
libtry-tiny-perl,
Modified: trunk/libplack-perl/eg/dot-psgi/static.psgi
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/eg/dot-psgi/static.psgi?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/eg/dot-psgi/static.psgi (original)
+++ trunk/libplack-perl/eg/dot-psgi/static.psgi Tue Jun 7 10:01:13 2011
@@ -6,6 +6,7 @@
};
builder {
+ enable "Plack::Middleware::ConditionalGET";
enable "Plack::Middleware::Static",
path => qr/./, root => dirname(__FILE__) . '/static';
$handler;
Modified: trunk/libplack-perl/lib/HTTP/Server/PSGI.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/lib/HTTP/Server/PSGI.pm?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/lib/HTTP/Server/PSGI.pm (original)
+++ trunk/libplack-perl/lib/HTTP/Server/PSGI.pm Tue Jun 7 10:01:13 2011
@@ -40,7 +40,10 @@
timeout => $args{timeout} || 300,
server_software => $args{server_software} || $class,
server_ready => $args{server_ready} || sub {},
- max_reqs_per_child => $args{max_reqs_per_child} || 100,
+ ssl => $args{ssl},
+ ipv6 => $args{ipv6},
+ ssl_key_file => $args{ssl_key_file},
+ ssl_cert_file => $args{ssl_cert_file},
}, $class;
if ($args{max_workers} && $args{max_workers} > 1) {
@@ -59,32 +62,58 @@
$self->accept_loop($app);
}
+sub prepare_socket_class {
+ my($self, $args) = @_;
+
+ if ($self->{ssl} && $self->{ipv6}) {
+ Carp::croak("SSL and IPv6 are not supported at the same time (yet). Choose one.");
+ }
+
+ if ($self->{ssl}) {
+ eval { require IO::Socket::SSL; 1 }
+ or Carp::croak("SSL suport requires IO::Socket::SSL");
+ $args->{SSL_key_file} = $self->{ssl_key_file};
+ $args->{SSL_cert_file} = $self->{ssl_cert_file};
+ return "IO::Socket::SSL";
+ } elsif ($self->{ipv6}) {
+ eval { require IO::Socket::IP; 1 }
+ or Carp::croak("IPv6 support requires IO::Socket::IP");
+ $self->{host} ||= '::1';
+ $args->{LocalAddr} ||= '::1';
+ return "IO::Socket::IP";
+ }
+
+ return "IO::Socket::INET";
+}
+
sub setup_listener {
my $self = shift;
- $self->{listen_sock} ||= IO::Socket::INET->new(
+
+ my %args = (
Listen => SOMAXCONN,
LocalPort => $self->{port},
LocalAddr => $self->{host},
Proto => 'tcp',
ReuseAddr => 1,
- ) or die "failed to listen to port $self->{port}:$!";
+ );
+
+ my $class = $self->prepare_socket_class(\%args);
+ $self->{listen_sock} ||= $class->new(%args)
+ or die "failed to listen to port $self->{port}: $!";
$self->{server_ready}->($self);
}
sub accept_loop {
- # TODO handle $max_reqs_per_child
- my($self, $app, $max_reqs_per_child) = @_;
- my $proc_req_count = 0;
+ my($self, $app) = @_;
$app = Plack::Middleware::ContentLength->wrap($app);
- while (! defined $max_reqs_per_child || $proc_req_count < $max_reqs_per_child) {
+ while (1) {
local $SIG{PIPE} = 'IGNORE';
if (my $conn = $self->{listen_sock}->accept) {
$conn->setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
or die "setsockopt(TCP_NODELAY) failed:$!";
- ++$proc_req_count;
my $env = {
SERVER_PORT => $self->{port},
SERVER_NAME => $self->{host},
@@ -92,7 +121,7 @@
REMOTE_ADDR => $conn->peerhost,
'psgi.version' => [ 1, 1 ],
'psgi.errors' => *STDERR,
- 'psgi.url_scheme' => 'http',
+ 'psgi.url_scheme' => $self->{ssl} ? 'https' : 'http',
'psgi.run_once' => Plack::Util::FALSE,
'psgi.multithread' => Plack::Util::FALSE,
'psgi.multiprocess' => Plack::Util::FALSE,
Modified: trunk/libplack-perl/lib/Plack.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/lib/Plack.pm?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/lib/Plack.pm (original)
+++ trunk/libplack-perl/lib/Plack.pm Tue Jun 7 10:01:13 2011
@@ -3,7 +3,7 @@
use strict;
use warnings;
use 5.008_001;
-our $VERSION = '0.9979';
+our $VERSION = '0.9980';
$VERSION = eval $VERSION;
1;
Modified: trunk/libplack-perl/lib/Plack/HTTPParser.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/lib/Plack/HTTPParser.pm?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/lib/Plack/HTTPParser.pm (original)
+++ trunk/libplack-perl/lib/Plack/HTTPParser.pm Tue Jun 7 10:01:13 2011
@@ -36,6 +36,10 @@
to Kazuho Oku's XS based HTTP::Parser::XS or pure perl fallback based
on David Robins HTTP::Parser.
+If you want to force the use of the slower pure perl version even if the
+fast XS version is available, set the environment variable
+C<PLACK_HTTP_PARSER_PP> to 1.
+
=head1 SEE ALSO
L<HTTP::Parser::XS> L<HTTP::Parser>
Modified: trunk/libplack-perl/lib/Plack/HTTPParser/PP.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/lib/Plack/HTTPParser/PP.pm?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/lib/Plack/HTTPParser/PP.pm (original)
+++ trunk/libplack-perl/lib/Plack/HTTPParser/PP.pm Tue Jun 7 10:01:13 2011
@@ -52,6 +52,8 @@
$env->{REQUEST_URI} = $uri;
my($path, $query) = ( $uri =~ /^([^?]*)(?:\?(.*))?$/s );
+ for ($path, $query) { s/\#.*$// if length } # dumb clients sending URI fragments
+
$env->{PATH_INFO} = URI::Escape::uri_unescape($path);
$env->{QUERY_STRING} = $query || '';
$env->{SCRIPT_NAME} = '';
Modified: trunk/libplack-perl/lib/Plack/Loader.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/lib/Plack/Loader.pm?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/lib/Plack/Loader.pm (original)
+++ trunk/libplack-perl/lib/Plack/Loader.pm Tue Jun 7 10:01:13 2011
@@ -75,8 +75,6 @@
return "Corona";
} elsif (exists $INC{"POE.pm"}) {
return "POE";
- } elsif (exists $INC{"Danga/Socket.pm"}) {
- return "Danga::Socket";
} else {
return "Standalone";
}
@@ -132,8 +130,9 @@
=item %INC
-If one of L<AnyEvent>, L<Coro>, L<POE> or L<Danga::Socket> is loaded,
-the relevant implementation will be loaded.
+If one of L<AnyEvent>, L<Coro> or L<POE> is loaded, the relevant
+server implementation such as L<Twiggy>, L<Corona> or
+L<POE::Component::Server::PSGI> will be loaded, if they're available.
=back
Modified: trunk/libplack-perl/lib/Plack/Loader/Restarter.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/lib/Plack/Loader/Restarter.pm?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/lib/Plack/Loader/Restarter.pm (original)
+++ trunk/libplack-perl/lib/Plack/Loader/Restarter.pm Tue Jun 7 10:01:13 2011
@@ -42,7 +42,6 @@
warn "Killing the existing server (pid:$pid)\n";
kill 'TERM' => $pid;
waitpid($pid, 0);
- warn "Successfully killed! Restarting the new server process.\n";
}
sub valid_file {
@@ -59,6 +58,7 @@
require Filesys::Notify::Simple;
my $watcher = Filesys::Notify::Simple->new($self->{watch});
warn "Watching @{$self->{watch}} for file updates.\n";
+ local $SIG{TERM} = sub { $self->_kill_child };
while (1) {
my @restart;
@@ -79,6 +79,7 @@
}
$self->_kill_child;
+ warn "Successfully killed! Restarting the new server process.\n";
$self->_fork_and_start($server, $builder);
return unless $self->{pid};
}
Modified: trunk/libplack-perl/lib/Plack/Middleware/AccessLog.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/lib/Plack/Middleware/AccessLog.pm?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/lib/Plack/Middleware/AccessLog.pm (original)
+++ trunk/libplack-perl/lib/Plack/Middleware/AccessLog.pm Tue Jun 7 10:01:13 2011
@@ -72,6 +72,7 @@
T => sub { $opts->{time} ? int($opts->{time}) : "-" },
D => sub { $opts->{time} ? $opts->{time} * 1000000 : "-" },
v => sub { $env->{SERVER_NAME} || '-' },
+ V => sub { $env->{HTTP_HOST} || $env->{SERVER_NAME} || '-' },
);
my $char_handler = sub {
@@ -130,7 +131,8 @@
Plack::Middleware::AccessLog forwards the request to the given app and
logs request and response details to the logger callback. The format
can be specified using Apache-like format strings (or C<combined> or
-C<common> for the default formats).
+C<common> for the default formats). If none is specified C<combined> is
+used.
This middleware uses calculable content-length by checking body type,
and can not log the time taken to serve requests. It also logs the
Modified: trunk/libplack-perl/lib/Plack/Middleware/ConditionalGET.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/lib/Plack/Middleware/ConditionalGET.pm?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/lib/Plack/Middleware/ConditionalGET.pm (original)
+++ trunk/libplack-perl/lib/Plack/Middleware/ConditionalGET.pm Tue Jun 7 10:01:13 2011
@@ -48,12 +48,12 @@
=head1 NAME
-Plack::Middleware::ConditionalGET - Middleware to add "conditional", GET
+Plack::Middleware::ConditionalGET - Middleware to enable conditional GET
=head1 SYNOPSIS
builder {
- enable "Plack::Middleware::ConditionalGET";
+ enable "ConditionalGET";
....
};
Modified: trunk/libplack-perl/lib/Plack/Request.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/lib/Plack/Request.pm?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/lib/Plack/Request.pm (original)
+++ trunk/libplack-perl/lib/Plack/Request.pm Tue Jun 7 10:01:13 2011
@@ -2,7 +2,7 @@
use strict;
use warnings;
use 5.008_001;
-our $VERSION = '0.9979';
+our $VERSION = '0.9980';
$VERSION = eval $VERSION;
use HTTP::Headers;
Modified: trunk/libplack-perl/lib/Plack/Response.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/lib/Plack/Response.pm?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/lib/Plack/Response.pm (original)
+++ trunk/libplack-perl/lib/Plack/Response.pm Tue Jun 7 10:01:13 2011
@@ -1,7 +1,7 @@
package Plack::Response;
use strict;
use warnings;
-our $VERSION = '0.9979';
+our $VERSION = '0.9980';
$VERSION = eval $VERSION;
use Plack::Util::Accessor qw(body status);
Modified: trunk/libplack-perl/lib/Plack/Server/ServerSimple.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/lib/Plack/Server/ServerSimple.pm?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/lib/Plack/Server/ServerSimple.pm (original)
+++ trunk/libplack-perl/lib/Plack/Server/ServerSimple.pm Tue Jun 7 10:01:13 2011
@@ -1,6 +1,6 @@
package Plack::Server::ServerSimple;
use strict;
-our $VERSION = '0.9979';
+our $VERSION = '0.9980';
$VERSION = eval $VERSION;
use parent qw(Plack::Handler::HTTP::Server::Simple);
Modified: trunk/libplack-perl/lib/Plack/Test/Suite.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/lib/Plack/Test/Suite.pm?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/lib/Plack/Test/Suite.pm (original)
+++ trunk/libplack-perl/lib/Plack/Test/Suite.pm Tue Jun 7 10:01:13 2011
@@ -622,6 +622,17 @@
},
],
[
+ 'newlines',
+ sub {
+ my $cb = shift;
+ my $res = $cb->(GET "http://127.0.0.1/");
+ is length($res->content), 7;
+ },
+ sub {
+ return [ 200, [ "Content-Type", "text/plain" ], [ "Bar\nBaz" ] ];
+ },
+ ],
+ [
'test 404',
sub {
my $cb = shift;
Modified: trunk/libplack-perl/scripts/plackup
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/scripts/plackup?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/scripts/plackup (original)
+++ trunk/libplack-perl/scripts/plackup Tue Jun 7 10:01:13 2011
@@ -123,6 +123,11 @@
environment variable or use the C<-s> or C<--server> flag which will
be preferred over the environment variable if present.
+If this option is not given, plackup will try to detect the I<best>
+server implementation based on the environment variables as well as
+modules loaded by your application in C<%INC>. See L<Plack::Loader>
+for details.
+
=item -S, --socket
UNIX domain socket path to listen on. Defaults to undef. This option
@@ -172,6 +177,11 @@
watches the C<lib> directory and the base directory where I<.psgi>
file is located. Use C<-R> if you want to watch other directories.
+Because C<-r> option (or C<-R>, see below) will delay the compilation
+of your application, automatic server detection (See the explanation
+of C<-s> above) depending on the modules used in your application will
+fail. You're recommended to explicitly specify C<-s> in such cases.
+
=item -R, --Reload
C<-R> option allows you to specify the path to watch file updates
Modified: trunk/libplack-perl/t/FCGIUtils.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/t/FCGIUtils.pm?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/t/FCGIUtils.pm (original)
+++ trunk/libplack-perl/t/FCGIUtils.pm Tue Jun 7 10:01:13 2011
@@ -11,29 +11,7 @@
# this file is copied from Catalyst. thanks!
-our @EXPORT = qw/ test_lighty_external test_fcgi_standalone /;
-
-# test using FCGI::Client + FCGI External Server
-sub test_fcgi_standalone {
- my ($callback, $http_port, $fcgi_port) = @_;
-
- $http_port ||= empty_port();
- $fcgi_port ||= empty_port($http_port);
-
- require Plack::App::FCGIDispatcher;
- my $fcgi_app = Plack::App::FCGIDispatcher->new({ port => $fcgi_port })->to_app;
-
- test_tcp(
- server => sub {
- my $server = Plack::Loader->load('Standalone', host => '127.0.0.1', port => $http_port);
- $server->run($fcgi_app);
- },
- client => sub {
- $callback->($http_port, $fcgi_port);
- },
- port => $http_port,
- );
-}
+our @EXPORT = qw/ test_lighty_external /;
# test for FCGI External Server
sub test_lighty_external (&@) {
Modified: trunk/libplack-perl/t/Plack-HTTPParser-PP/simple.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libplack-perl/t/Plack-HTTPParser-PP/simple.t?rev=75225&op=diff
==============================================================================
--- trunk/libplack-perl/t/Plack-HTTPParser-PP/simple.t (original)
+++ trunk/libplack-perl/t/Plack-HTTPParser-PP/simple.t Tue Jun 7 10:01:13 2011
@@ -1,4 +1,4 @@
-use Test::More tests => 6;
+use Test::More tests => 12;
use Plack::HTTPParser::PP;
*parse_http_request = \&Plack::HTTPParser::PP::parse_http_request;
@@ -61,3 +61,52 @@
SCRIPT_NAME => '',
SERVER_PROTOCOL => 'HTTP/1.0',
}, 'multiline');
+
+# dumb HTTP client: https://github.com/miyagawa/Plack/issues/213
+$req = <<"EOT";
+GET /a/b#c HTTP/1.0\r
+\r
+EOT
+%env = ();
+is(parse_http_request($req, \%env), length($req), 'URI fragment');
+is_deeply(\%env, {
+ SCRIPT_NAME => '',
+ PATH_INFO => '/a/b',
+ REQUEST_METHOD => 'GET',
+ REQUEST_URI => '/a/b#c',
+ QUERY_STRING => '',
+ SCRIPT_NAME => '',
+ SERVER_PROTOCOL => 'HTTP/1.0',
+});
+
+$req = <<"EOT";
+GET /a/b%23c HTTP/1.0\r
+\r
+EOT
+%env = ();
+is(parse_http_request($req, \%env), length($req), '%23 -> #');
+is_deeply(\%env, {
+ SCRIPT_NAME => '',
+ PATH_INFO => '/a/b#c',
+ REQUEST_METHOD => 'GET',
+ REQUEST_URI => '/a/b%23c',
+ QUERY_STRING => '',
+ SCRIPT_NAME => '',
+ SERVER_PROTOCOL => 'HTTP/1.0',
+});
+
+$req = <<"EOT";
+GET /a/b?c=d#e HTTP/1.0\r
+\r
+EOT
+%env = ();
+is(parse_http_request($req, \%env), length($req), 'URI fragment after query string');
+is_deeply(\%env, {
+ SCRIPT_NAME => '',
+ PATH_INFO => '/a/b',
+ REQUEST_METHOD => 'GET',
+ REQUEST_URI => '/a/b?c=d#e',
+ QUERY_STRING => 'c=d',
+ SCRIPT_NAME => '',
+ SERVER_PROTOCOL => 'HTTP/1.0',
+});
More information about the Pkg-perl-cvs-commits
mailing list