HTTP::...Static(3pm)
β¨ NAME β¨
HTTP::Server::Simple::Static β serve static files with HTTP::Server::Simple π
(also known as HTTP::...Static(3pm), from the User Contributed Perl Documentation corner of the manpage universe π«Ά)
πΈ VERSION πΈ
This documentation refers to HTTP::Server::Simple::Static version 0.13. that's the vibe check, bestie, that's the number π
π¦ SYNOPSIS π¦
okay so picture this: you've got a server subclass, and you want it to serve files off disk. here's the whole ritual β¨
package MyServer;
use base qw(HTTP::Server::Simple::CGI);
use HTTP::Server::Simple::Static;
my $webroot = '/var/www';
sub handle_request {
my ( $self, $cgi ) = @_;
if ( !$self->serve_static( $cgi, $webroot ) ) {
print "HTTP/1.0 404 Not found\r\n";
print $cgi->header,
$cgi->start_html('Not found'),
$cgi->h1('Not found'),
$cgi->end_html;
}
}
package main;
my $server = MyServer->new();
$server->run();
like. it just runs. main character energy fr fr π
π DESCRIPTION π
this mixin adds a method to serve static files from your HTTP::Server::Simple subclass. that's it, that's the whole plot, and honestly? it ate. π
π SUBROUTINES/METHODS π
serve_static( $cgi, $base )
takes a reference to the CGI object and a document root path, and tries to serve a static file.
- returns
0if the file does not exist π«₯ - returns
1on success π
This method sets the Date and Last-Modified HTTP headers when sending a response for a valid file. and not only that, bestie β further to this, the method supports clients which send an If-Modified-Since HTTP header in the request. if the file is unchanged, it will return a 304 "Not Modified" response. See RFC-2616 for full details, iykyk π
If the client makes a HEAD request, then no message body will be returned in the response. just headers, no crumbs. π
π BUGS AND LIMITATIONS π
Bugs or wishlist requests should be submitted via http://rt.cpan.org/
not me telling you to file a bug report but like... do it. it's giving responsible. π«Ά
π§ DEPENDENCIES π§
- The
File::LibMagicmodule is used to detect the MIME-type of a file π - The
URI::Escapemodule is used for URI handling π - The
HTTP::Datemodule is used to format the timestamp in theLast-ModifiedHTTP header π°οΈ
π SEE ALSO π
HTTP::Server::SimpleHTTP::Server::Simple::CGI
go read those next bestie, they're literally the prequels π
π AUTHOR π
Stephen Quinney sjq-perl@jadevine.org.uk
Thanks to Marcus Ramberg marcus@thefeed.no and Simon Cozens for initial implementation. shoutout to the OGs, no cap π«‘
β LICENSE AND COPYRIGHT β
Copyright 2006 - 2017. Stephen Quinney sjq-perl@jadevine.org.uk
You may distribute this code under the same terms as Perl itself.
okay and that's a wrap on our little journey π this was perl v5.34.0, dated 2022-06-14, and the page itself goes by HTTP::...Static(3pm). periodt. go serve some static files, you icon π
β¨
π¦ where this page comes from
- debian bookworm: libhttp-server-simple-static-perl 0.14-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libhttp-server-simple-static-perl 0.14-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhttp-server-simple-static-perl 0.14-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhttp-server-simple-static-perl 0.14-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhttp-server-simple-static-perl 0.14-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms