From 5f51bef4f8357e0103bcbf6cfa2423a406ebfcb6 Mon Sep 17 00:00:00 2001 From: Tatsuhiko Miyagawa Date: Mon, 4 May 2026 23:34:12 -0700 Subject: [PATCH] Revert "Plack::App::File check REQUEST_METHOD after locating file" --- lib/Plack/App/File.pm | 3 --- t/Plack-Middleware/static.t | 8 +------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/lib/Plack/App/File.pm b/lib/Plack/App/File.pm index 2d6448f00..b169a526f 100644 --- a/lib/Plack/App/File.pm +++ b/lib/Plack/App/File.pm @@ -22,9 +22,6 @@ sub call { 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 0650611bb..0865a0baf 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,12 +77,6 @@ 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';