Permalink
Browse files

Merge pull request #348 from avar/avar/PSGI-compliant-content-length-…

…for-plack-handler-apache2

Plack::Handler::Apache2: normalize duplicate Content-Length headers
  • Loading branch information...
2 parents 443325f + 9bf7e8f commit 40f7d02131984e5b14677c464f1c8b1ca948c91b @miyagawa miyagawa committed Nov 8, 2012
Showing with 9 additions and 0 deletions.
  1. +9 −0 lib/Plack/Handler/Apache2.pm
@@ -68,6 +68,15 @@ sub call_app {
$env->{HTTP_AUTHORIZATION} = $HTTP_AUTHORIZATION;
}
+ # If you supply more than one Content-Length header Apache will
+ # happily concat the values with ", ", e.g. "72, 72". This
+ # violates the PSGI spec so fix this up and just take the first
+ # one.
+ if (exists $env->{CONTENT_LENGTH} && $env->{CONTENT_LENGTH} =~ /,/) {
+ no warnings qw(numeric);
+ $env->{CONTENT_LENGTH} = int $env->{CONTENT_LENGTH};
+ }
+
# Actually, we can not trust PATH_INFO from mod_perl because mod_perl squeezes multiple slashes into one slash.
my $uri = URI->new("http://".$r->hostname.$r->unparsed_uri);

0 comments on commit 40f7d02

Please sign in to comment.