Skip to content

Commit

Permalink
Plack::Middleware::XSendfile ignore HEAD requests plack#688
Browse files Browse the repository at this point in the history
  • Loading branch information
robrwo committed Dec 21, 2022
1 parent 7d40112 commit f9b011f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Plack/Middleware/XSendfile.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ sub call {
my $res = shift;
my($status, $headers, $body) = @$res;
return unless defined $body;
return if $env->{REQUEST_METHOD} eq 'HEAD';

if (Scalar::Util::blessed($body) && $body->can('path')) {
my $type = $self->_variation($env) || '';
Expand Down
5 changes: 5 additions & 0 deletions t/Plack-Middleware/xsendfile.t
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ test_psgi app => $handler, client => sub {
is $res->content, '';
is $res->header('Content-Length'), 0, 'Content-Length 0';
}

{
my $res = $cb->(HEAD "http://localhost/t/test.txt", 'X-Sendfile-Type' => 'X-Sendfile');
ok !$res->header('X-Sendfile'), 'no pass through app header for HEAD requests';
}
};

test_psgi(
Expand Down

0 comments on commit f9b011f

Please sign in to comment.