diff --git a/lib/Plack/App/File.pm b/lib/Plack/App/File.pm index 22cb820c..e6430c37 100644 --- a/lib/Plack/App/File.pm +++ b/lib/Plack/App/File.pm @@ -19,12 +19,12 @@ sub call { my $self = shift; my $env = shift; - my $method = $env->{REQUEST_METHOD}; - return $self->return_405 unless $method eq 'GET' || $method eq 'HEAD'; - my($file, $path_info) = $self->file || $self->locate_file($env); return $file if ref $file eq 'ARRAY'; + my $method = $env->{REQUEST_METHOD}; + return $self->return_405 unless $method eq 'GET' || $method eq 'HEAD'; + if ($path_info) { $env->{'plack.file.SCRIPT_NAME'} = $env->{SCRIPT_NAME} . $env->{PATH_INFO}; $env->{'plack.file.SCRIPT_NAME'} =~ s/\Q$path_info\E$//; diff --git a/t/Plack-Middleware/static.t b/t/Plack-Middleware/static.t index 2a7af76e..a62a76cc 100644 --- a/t/Plack-Middleware/static.t +++ b/t/Plack-Middleware/static.t @@ -24,7 +24,7 @@ my $handler = builder { enable "Plack::Middleware::Static", path => qr{\.(t|PL|txt)$}i, root => '.'; enable "Plack::Middleware::Static", - path => qr{\.foo$}i, root => '.', + path => qr{\.foo$}i, root => '.', content_type => sub { substr Plack::MIME->mime_type($_[0]),0,-1 } ; sub { [200, ['Content-Type' => 'text/plain', 'Content-Length' => 2], ['ok']] @@ -77,6 +77,12 @@ my %test = ( is $res->content, 'ok'; } + { + my $res = $cb->(POST "http://localhost/share-pass/faceX.jpg"); + is $res->code, 200, 'pass through (POST)'; + is $res->content, 'ok'; + } + { my $res = $cb->(GET "http://localhost/t/Plack-Middleware/static.txt"); is $res->content_type, 'text/plain';