1HTTP::Server::Simple::SUtsaetricC(o3n)tributed Perl DocuHmTeTnPt:a:tSieornver::Simple::Static(3)
2
3
4

NAME

6       HTTP::Server::Simple::Static - Serve static files with
7       HTTP::Server::Simple
8

VERSION

10       This documentation refers to HTTP::Server::Simple::Static version 0.13
11

SYNOPSIS

13           package MyServer;
14
15           use base qw(HTTP::Server::Simple::CGI);
16           use HTTP::Server::Simple::Static;
17
18           my $webroot = '/var/www';
19
20           sub handle_request {
21               my ( $self, $cgi ) = @_;
22
23               if ( !$self->serve_static( $cgi, $webroot ) ) {
24                   print "HTTP/1.0 404 Not found\r\n";
25                   print $cgi->header,
26                         $cgi->start_html('Not found'),
27                         $cgi->h1('Not found'),
28                         $cgi->end_html;
29               }
30           }
31
32           package main;
33
34           my $server = MyServer->new();
35           $server->run();
36

DESCRIPTION

38       this mixin adds a method to serve static files from your
39       HTTP::Server::Simple subclass.
40

SUBROUTINES/METHODS

42       serve_static( $cgi, $base )
43           Takes a reference to the CGI object and a document root path, and
44           tries to serve a static file. Returns 0 if the file does not exist,
45           returns 1 on success.
46
47           This method sets the "Date" and "Last-Modified" HTTP headers when
48           sending a response for a valid file. Further to this, the method
49           supports clients which send an "If-Modified-Since" HTTP header in
50           the request, it will return a 304 "Not Modified" response if the
51           file is unchanged. See RFC-2616 for full details.
52
53           If the client makes a "HEAD" request then no message body will be
54           returned in the response.
55

BUGS AND LIMITATIONS

57       Bugs or wishlist requests should be submitted via http://rt.cpan.org/
58

DEPENDENCIES

60       The File::LibMagic module is used to detect the MIME-type of a file.
61       The URI::Escape module is used for URI handling. The HTTP::Date module
62       is used to format the timestamp in the Last-Modified HTTP header.
63

SEE ALSO

65       HTTP::Server::Simple, HTTP::Server::Simple::CGI
66

AUTHOR

68       Stephen Quinney "sjq-perl@jadevine.org.uk"
69
70       Thanks to Marcus Ramberg "marcus@thefeed.no" and Simon Cozens for
71       initial implementation.
72
74       Copyright 2006 - 2017. Stephen Quinney "sjq-perl@jadevine.org.uk"
75
76       You may distribute this code under the same terms as Perl itself.
77
78
79
80perl v5.34.0                      2021-07-22   HTTP::Server::Simple::Static(3)
Impressum