r75223 - in /branches/upstream/libplack-perl/current: ./ 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 09:53:34 UTC 2011


Author: ghedo-guest
Date: Tue Jun  7 09:52:46 2011
New Revision: 75223

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

Removed:
    branches/upstream/libplack-perl/current/lib/Plack/App/FCGIDispatcher.pm
    branches/upstream/libplack-perl/current/t/Plack-Handler/fcgi_client.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/Makefile.PL
    branches/upstream/libplack-perl/current/eg/dot-psgi/static.psgi
    branches/upstream/libplack-perl/current/lib/HTTP/Server/PSGI.pm
    branches/upstream/libplack-perl/current/lib/Plack.pm
    branches/upstream/libplack-perl/current/lib/Plack/HTTPParser.pm
    branches/upstream/libplack-perl/current/lib/Plack/HTTPParser/PP.pm
    branches/upstream/libplack-perl/current/lib/Plack/Loader.pm
    branches/upstream/libplack-perl/current/lib/Plack/Loader/Restarter.pm
    branches/upstream/libplack-perl/current/lib/Plack/Middleware/AccessLog.pm
    branches/upstream/libplack-perl/current/lib/Plack/Middleware/ConditionalGET.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/Test/Suite.pm
    branches/upstream/libplack-perl/current/scripts/plackup
    branches/upstream/libplack-perl/current/t/FCGIUtils.pm
    branches/upstream/libplack-perl/current/t/Plack-HTTPParser-PP/simple.t

Modified: branches/upstream/libplack-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/Changes?rev=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/Changes (original)
+++ branches/upstream/libplack-perl/current/Changes Tue Jun  7 09:52:46 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: branches/upstream/libplack-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/MANIFEST?rev=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/MANIFEST (original)
+++ branches/upstream/libplack-perl/current/MANIFEST Tue Jun  7 09:52:46 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: branches/upstream/libplack-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/META.yml?rev=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/META.yml (original)
+++ branches/upstream/libplack-perl/current/META.yml Tue Jun  7 09:52:46 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: branches/upstream/libplack-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/Makefile.PL?rev=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/Makefile.PL (original)
+++ branches/upstream/libplack-perl/current/Makefile.PL Tue Jun  7 09:52:46 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: branches/upstream/libplack-perl/current/eg/dot-psgi/static.psgi
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/eg/dot-psgi/static.psgi?rev=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/eg/dot-psgi/static.psgi (original)
+++ branches/upstream/libplack-perl/current/eg/dot-psgi/static.psgi Tue Jun  7 09:52:46 2011
@@ -6,6 +6,7 @@
 };
 
 builder {
+    enable "Plack::Middleware::ConditionalGET";
     enable "Plack::Middleware::Static",
         path => qr/./, root => dirname(__FILE__) . '/static';
     $handler;

Modified: branches/upstream/libplack-perl/current/lib/HTTP/Server/PSGI.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/HTTP/Server/PSGI.pm?rev=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/HTTP/Server/PSGI.pm (original)
+++ branches/upstream/libplack-perl/current/lib/HTTP/Server/PSGI.pm Tue Jun  7 09:52:46 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: 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=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack.pm Tue Jun  7 09:52:46 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: branches/upstream/libplack-perl/current/lib/Plack/HTTPParser.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/HTTPParser.pm?rev=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/HTTPParser.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/HTTPParser.pm Tue Jun  7 09:52:46 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: branches/upstream/libplack-perl/current/lib/Plack/HTTPParser/PP.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/HTTPParser/PP.pm?rev=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/HTTPParser/PP.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/HTTPParser/PP.pm Tue Jun  7 09:52:46 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: branches/upstream/libplack-perl/current/lib/Plack/Loader.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Loader.pm?rev=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Loader.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Loader.pm Tue Jun  7 09:52:46 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: branches/upstream/libplack-perl/current/lib/Plack/Loader/Restarter.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Loader/Restarter.pm?rev=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Loader/Restarter.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Loader/Restarter.pm Tue Jun  7 09:52:46 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: 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=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Middleware/AccessLog.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Middleware/AccessLog.pm Tue Jun  7 09:52:46 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: branches/upstream/libplack-perl/current/lib/Plack/Middleware/ConditionalGET.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Middleware/ConditionalGET.pm?rev=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Middleware/ConditionalGET.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Middleware/ConditionalGET.pm Tue Jun  7 09:52:46 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: 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=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Request.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Request.pm Tue Jun  7 09:52:46 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: 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=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Response.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Response.pm Tue Jun  7 09:52:46 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: 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=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Server/ServerSimple.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Server/ServerSimple.pm Tue Jun  7 09:52:46 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: branches/upstream/libplack-perl/current/lib/Plack/Test/Suite.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/lib/Plack/Test/Suite.pm?rev=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/lib/Plack/Test/Suite.pm (original)
+++ branches/upstream/libplack-perl/current/lib/Plack/Test/Suite.pm Tue Jun  7 09:52:46 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: branches/upstream/libplack-perl/current/scripts/plackup
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/scripts/plackup?rev=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/scripts/plackup (original)
+++ branches/upstream/libplack-perl/current/scripts/plackup Tue Jun  7 09:52:46 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: branches/upstream/libplack-perl/current/t/FCGIUtils.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/t/FCGIUtils.pm?rev=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/t/FCGIUtils.pm (original)
+++ branches/upstream/libplack-perl/current/t/FCGIUtils.pm Tue Jun  7 09:52:46 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: branches/upstream/libplack-perl/current/t/Plack-HTTPParser-PP/simple.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libplack-perl/current/t/Plack-HTTPParser-PP/simple.t?rev=75223&op=diff
==============================================================================
--- branches/upstream/libplack-perl/current/t/Plack-HTTPParser-PP/simple.t (original)
+++ branches/upstream/libplack-perl/current/t/Plack-HTTPParser-PP/simple.t Tue Jun  7 09:52:46 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