[Bps-public-commit] HTTP-Server-Simple branch, master, updated. 0.41_01-2-g1da1edb

jesse jesse at bestpractical.com
Thu Feb 4 15:24:44 EST 2010


The branch, master has been updated
       via  1da1edbfc008c7cf86236bfca65ac51b2b69903c (commit)
       via  d56eaf4d9097e11a1bd1c44b147c4304de3031a9 (commit)
      from  7c843049dfea8e9aa78c8e33d233c7c167ab8add (commit)

Summary of changes:
 Makefile.PL                               |    1 -
 lib/HTTP/Server/Simple.pm                 |    1 -
 lib/HTTP/Server/Simple/CGI/Environment.pm |    4 ++--
 t/04cgi.t                                 |   11 +++++++++--
 4 files changed, 11 insertions(+), 6 deletions(-)

- Log -----------------------------------------------------------------
commit d56eaf4d9097e11a1bd1c44b147c4304de3031a9
Author: Tatsuhiko Miyagawa <miyagawa at bulknews.net>
Date:   Thu Feb 4 11:41:56 2010 -0800

    Do not special case COOKIE and sets Cookie header to HTTP_COOKIE.
    
    O'Reilly's WebSite server misuses COOKIE environment instead of
    HTTP_COOKIE. We don't need to replicate that bug since
    HTTP::Server::Simple is a server, not a CGI library like CGI.pm.
    
    http://www.google.com/codesearch?hl=en&lr=&q=HTTP_COOKIE+o%27reilly+web+server

diff --git a/lib/HTTP/Server/Simple/CGI/Environment.pm b/lib/HTTP/Server/Simple/CGI/Environment.pm
index 3d3565c..758eaa5 100644
--- a/lib/HTTP/Server/Simple/CGI/Environment.pm
+++ b/lib/HTTP/Server/Simple/CGI/Environment.pm
@@ -102,7 +102,7 @@ sub header {
     $tag =~ s/^COOKIES$/COOKIE/;
     $tag =~ s/-/_/g;
     $tag = "HTTP_" . $tag
-        unless $tag =~ m/^(?:CONTENT_(?:LENGTH|TYPE)|COOKIE)$/;
+        unless $tag =~ m/^CONTENT_(?:LENGTH|TYPE)$/;
 
     if ( exists $ENV{$tag} ) {
         $ENV{$tag} .= ", $value";
diff --git a/t/04cgi.t b/t/04cgi.t
index 0810cd5..2c3317f 100644
--- a/t/04cgi.t
+++ b/t/04cgi.t
@@ -2,7 +2,7 @@ use Test::More;
 use Socket;
 use strict;
 
-plan tests => 22;
+plan tests => 23;
 my $PORT = 40000 + int(rand(10000));
 
 my $host = gethostbyaddr(inet_aton('localhost'), AF_INET);
@@ -14,6 +14,7 @@ my %methods=(
               server_port => 'server_port: '.$PORT,
               server_software => 'server_software: HTTP::Server::Simple/\d+.\d+',
               request_method => 'request_method: GET',
+              raw_cookie => undef, # do not test
             );
 
 my %envvars=(
@@ -42,6 +43,7 @@ my %envvars=(
   like(fetch("GET / HTTP/1.1",""), '/NOFILE/', 'no file');
 
   foreach my $method (keys(%methods)) {
+    next unless defined $methods{$method};
     like(
           fetch("GET /cgitest/$method HTTP/1.1",""),
           "/$methods{$method}/",
@@ -71,6 +73,11 @@ my %envvars=(
        "Did decode already"
       );
 
+  like(
+      fetch("GET /cgitest/raw_cookie HTTP/1.0","Cookie: foo=bar",""),
+      qr|foo=bar|,
+      "uses HTTP_COOKIE",
+  );
 
   is(kill(9,$pid),1,'Signaled 1 process successfully');
   wait or die "counldn't wait for sub-process completion";
@@ -135,7 +142,7 @@ sub fetch {
     print "HTTP/1.0 200 OK\r\n";    # probably OK by now
     print "Content-Type: text/html\r\nContent-Length: ";
     my $response;
-    if($methods{$file}) {
+    if(exists $methods{$file}) {
       $response = "$file: ".$cgi->$file();
     } elsif($envvars{$file}) {
       $response="$file: $ENV{$file}";

commit 1da1edbfc008c7cf86236bfca65ac51b2b69903c
Author: Tatsuhiko Miyagawa <miyagawa at bulknews.net>
Date:   Thu Feb 4 11:47:56 2010 -0800

    Inline uri_unescape to drop URI::Escape which is the only non-core
    dependency of this distribution.

diff --git a/Makefile.PL b/Makefile.PL
index 9f33342..8904a1a 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -7,7 +7,6 @@ requires(
     Socket      => 0,
     Test::More  => 0,
     CGI         => 0,
-    URI::Escape => 0
 );
 
 WriteAll( sign => 1);
diff --git a/lib/HTTP/Server/Simple.pm b/lib/HTTP/Server/Simple.pm
index 35c54da..599579a 100644
--- a/lib/HTTP/Server/Simple.pm
+++ b/lib/HTTP/Server/Simple.pm
@@ -5,7 +5,6 @@ package HTTP::Server::Simple;
 use FileHandle;
 use Socket;
 use Carp;
-use URI::Escape;
 
 use vars qw($VERSION $bad_request_doc);
 $VERSION = '0.41_01';
diff --git a/lib/HTTP/Server/Simple/CGI/Environment.pm b/lib/HTTP/Server/Simple/CGI/Environment.pm
index 758eaa5..df7e6e4 100644
--- a/lib/HTTP/Server/Simple/CGI/Environment.pm
+++ b/lib/HTTP/Server/Simple/CGI/Environment.pm
@@ -84,7 +84,7 @@ sub setup_environment_from_metadata {
 
     # Apache and lighttpd both do one layer of unescaping on
     # path_info; we should duplicate that.
-    $ENV{PATH_INFO} = URI::Escape::uri_unescape($ENV{PATH_INFO});
+    $ENV{PATH_INFO} =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
 }
 
 =head2  header

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list