Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/Plack/App/File.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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$//;
Expand Down
8 changes: 7 additions & 1 deletion t/Plack-Middleware/static.t
Original file line number Diff line number Diff line change
Expand Up @@ -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']]
Expand Down Expand Up @@ -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';
Expand Down