GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  HTTP::SERVER::SIMPLE::STATIC (3)

.ds Aq ’

NAME

HTTP::Server::Simple::Static - Serve static files with HTTP::Server::Simple

CONTENTS

VERSION

This documentation refers to HTTP::Server::Simple::Static version 0.07

SYNOPSIS



    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();



DESCRIPTION

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

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 0 if the file does not exist, returns 1 on success.

This method sets the Date and Last-Modified HTTP headers when sending a response for a valid file. Further to this, the method supports clients which send an If-Modified-Since HTTP header in the request, it will return a 304 Not Modified response if the file is unchanged. See RFC-2616 for full details.

If the client makes a HEAD request then no message body will be returned in the response.

BUGS AND LIMITATIONS

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

DEPENDENCIES

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

SEE ALSO

HTTP::Server::Simple, HTTP::Server::Simple::CGI

AUTHOR

Stephen Quinney sjq-perl@jadevine.org.uk

Thanks to Marcus Ramberg marcus@thefeed.no and Simon Cozens for initial implementation.

LICENSE AND COPYRIGHT

Copyright 2006 - 2013. Stephen Quinney sjq-perl@jadevine.org.uk

You may distribute this code under the same terms as Perl itself.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 HTTP::SERVER::SIMPLE::STATIC (3) 2016-04-03

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.