From e2d680ac7c6f0bb36808aa45e1453c8b585d2717 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Mon, 2 Feb 2015 15:36:39 +0000 Subject: HTTP-Server-Simple-0.50 --- lib/HTTP/Server/Simple.pm | 820 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 820 insertions(+) create mode 100644 lib/HTTP/Server/Simple.pm (limited to 'lib/HTTP/Server/Simple.pm') diff --git a/lib/HTTP/Server/Simple.pm b/lib/HTTP/Server/Simple.pm new file mode 100644 index 0000000..89b43e4 --- /dev/null +++ b/lib/HTTP/Server/Simple.pm @@ -0,0 +1,820 @@ +use strict; +use warnings; + +package HTTP::Server::Simple; +use FileHandle; +use Socket; +use Carp; + +use vars qw($VERSION $bad_request_doc); +$VERSION = '0.50'; + +=head1 NAME + +HTTP::Server::Simple - Lightweight HTTP server + +=head1 SYNOPSIS + + use warnings; + use strict; + + use HTTP::Server::Simple; + + my $server = HTTP::Server::Simple->new(); + $server->run(); + +However, normally you will sub-class the HTTP::Server::Simple::CGI +module (see L); + + package Your::Web::Server; + use base qw(HTTP::Server::Simple::CGI); + + sub handle_request { + my ($self, $cgi) = @_; + + #... do something, print output to default + # selected filehandle... + + } + + 1; + +=head1 DESCRIPTION + +This is a simple standalone HTTP server. By default, it doesn't thread +or fork. It does, however, act as a simple frontend which can be used +to build a standalone web-based application or turn a CGI into one. + +It is possible to use L classes to create forking, +pre-forking, and other types of more complicated servers; see +L. + +By default, the server traps a few signals: + +=over + +=item HUP + +When you C the server, it lets the current request finish being +processed, then uses the C method to re-exec itself. Please note that +in order to provide restart-on-SIGHUP, HTTP::Server::Simple sets a SIGHUP +handler during initialisation. If your request handling code forks you need to +make sure you reset this or unexpected things will happen if somebody sends a +HUP to all running processes spawned by your app (e.g. by "kill -HUP