Catalyst::Plugin::XSendFile - Catalyst plugin for lighttpd's X-Sendfile.
use Catalyst qw/XSendFile/; sub show : Path('/files') { my ( $self, $c, $filename ) = @_; # unless login, it shows 403 forbidden screen $c->res->status(403); $c->stash->{template} = 'error-403.tt'; # serving a static file only when user logged in. if ($c->user) { $c->res->sendfile( "/path/to/$filename" ); } }
lighty's X-Sendfile feature is great.
If you use lighttpd + fastcgi, you can show files only set X-Sendfile header like below:
$c->res->header( 'X-LIGHTTPD-send-file' => $filename );
This feature is especially great for serving static file on authentication area.
And with this plugin, you can use:
$c->res->sendfile( $filename );
instead of above.
But off-course you know, this feature doesn't work on Catalyst Test Server (myapp_server.pl). So this module also provide its emulation when your app on test server.
lighty's life - X-Sendfile http://blog.lighttpd.net/articles/2006/07/02/x-sendfile
To use it you have to set "allow-x-sendfile" option enabled in your fastcgi configuration.
"allow-x-send-file" => "enable",
Setup MIME::Types object unless Static::Simple loaded.
Added X-Sendfile emulation feature for test server.
Set X-LIGHTTPD-send-file header easily.
Daisuke Murase <typester@cpan.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
To install Catalyst::Plugin::XSendFile, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Plugin::XSendFile
CPAN shell
perl -MCPAN -e shell install Catalyst::Plugin::XSendFile
For more information on module installation, please visit the detailed CPAN module installation guide.