[Rt-commit] r3835 - in HTTP-Server-Simple: . lib/HTTP/Server
jesse at bestpractical.com
jesse at bestpractical.com
Thu Sep 8 08:16:27 EDT 2005
Author: jesse
Date: Thu Sep 8 08:16:26 2005
New Revision: 3835
Modified:
HTTP-Server-Simple/ (props changed)
HTTP-Server-Simple/Changes
HTTP-Server-Simple/META.yml
HTTP-Server-Simple/SIGNATURE
HTTP-Server-Simple/lib/HTTP/Server/Simple.pm
Log:
r15576 at hualien: jesse | 2005-09-08 08:09:31 -0400
* Signals handling fixes for Mark Fowler.
* 0.14_03
Modified: HTTP-Server-Simple/Changes
==============================================================================
--- HTTP-Server-Simple/Changes (original)
+++ HTTP-Server-Simple/Changes Thu Sep 8 08:16:26 2005
@@ -1,7 +1,9 @@
Split out HTTP::Server::Simple::CGI::Environment to support non-CGI.pm CGIs
Ignore SIGPIPE
-
+
+ Signal handlers are now installed on ->run, not on new. Also, they're
+ documented. Thanks to Mark Fowler.
0.13 Tue Aug 9 21:25:20 EDT 2005
Modified: HTTP-Server-Simple/META.yml
==============================================================================
--- HTTP-Server-Simple/META.yml (original)
+++ HTTP-Server-Simple/META.yml Thu Sep 8 08:16:26 2005
@@ -1,5 +1,5 @@
name: HTTP-Server-Simple
-version: 0.14_02
+version: 0.14_03
license: perl
distribution_type: module
requires:
Modified: HTTP-Server-Simple/SIGNATURE
==============================================================================
--- HTTP-Server-Simple/SIGNATURE (original)
+++ HTTP-Server-Simple/SIGNATURE Thu Sep 8 08:16:26 2005
@@ -14,9 +14,9 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-SHA1 c3f00505e54fc5a7aada2be16900aa6d59d5c194 Changes
+SHA1 7ea3dd9fcdcc2607cafa9c82edb70090297658c5 Changes
SHA1 0ac508c50476dcc2bf8fe3094cb341425291e1ee MANIFEST
-SHA1 6313a5050d0057df54c4f29c7248d1ee7c281e7c META.yml
+SHA1 c2533ce46b89fa0eb1e0c864548265ade18b241e META.yml
SHA1 490f3fd115e09cb05b725580e5ed5cdd58241049 Makefile.PL
SHA1 ed0c107672daac3bc9e266876666e1059dbe44b7 README
SHA1 4ea1e9072ca87399184a46233df52a21e285604d ex/sample_server
@@ -28,7 +28,7 @@
SHA1 e448c6dc5351ef425e3f8bdbeb642409120bc3ca inc/Module/Install/Metadata.pm
SHA1 134de6ff2f762873b6a1af950dd53f8e0a801d73 inc/Module/Install/Win32.pm
SHA1 1ec06df292af7f652d33db6129e9e4c7cc8b5095 inc/Module/Install/WriteAll.pm
-SHA1 7f72bec8b4d6dfba12a0c8dbc9e91392660188d8 lib/HTTP/Server/Simple.pm
+SHA1 f7db491bac7b362f278320d7b20eacd786ff0e91 lib/HTTP/Server/Simple.pm
SHA1 2d7348b166f654a460ddae4cb4183f4a544c85fc lib/HTTP/Server/Simple/CGI.pm
SHA1 b2c2d007a7f50058c874e633d15fb621b2bfc394 lib/HTTP/Server/Simple/CGI/Environment.pm
SHA1 db064af54cab345a71daec576e32e64b8fb1033d t/00smoke.t
@@ -39,7 +39,7 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
-iD8DBQFDHIh7Ei9d9xCOQEYRAtKaAJ4v25FqXkYIoK/+gGgf0bXv0NdQPwCglVwu
-m80vCVprXzunzBPl6NHi6/k=
-=4/Z3
+iD8DBQFDICmtEi9d9xCOQEYRAoTFAJsFd7pPRvKuk3Xv+jKNirjtKF/WygCcD+gb
+zaqfBZgDtraQcolBjG0gqkY=
+=MKBE
-----END PGP SIGNATURE-----
Modified: HTTP-Server-Simple/lib/HTTP/Server/Simple.pm
==============================================================================
--- HTTP-Server-Simple/lib/HTTP/Server/Simple.pm (original)
+++ HTTP-Server-Simple/lib/HTTP/Server/Simple.pm Thu Sep 8 08:16:26 2005
@@ -5,17 +5,12 @@
use Socket;
use Carp;
-our $VERSION = '0.14_02';
+our $VERSION = '0.14_03';
=head1 NAME
HTTP::Server::Simple
-=head1 WARNING
-
-This code is still undergoing active development. Particularly, the
-API is not yet frozen. Comments about the API would be greatly
-appreciated.
=head1 SYNOPSIS
@@ -45,41 +40,37 @@
=head1 DESCRIPTION
-This is a simple standalone http dameon. It doesn't thread. It doesn't
-fork.
+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 turn a CGI into a
-standalone web-based application.
+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.
-=head2 HTTP::Server::Simple->new($port)
+(It's possible to use Net::Server to get threading, forking,
+preforking and so on. Autrijus Tang wrote the functionality and owes docs for that ;)
-API call to start a new server. Does not actually start listening
-until you call C<-E<gt>run()>.
+By default, the server traps a few signals:
-=cut
+=over
-# Handle SIGHUP
+=item HUP
-local $SIG{CHLD} = 'IGNORE'; # reap child processes
-local $SIG{HUP} = sub {
- close HTTPDaemon;
-
- # and then, on systems implementing fork(), we make sure
- # we are running with a new pid, so another -HUP will still
- # work on the new process.
- require Config;
- if ( $Config::Config{d_fork} and my $pid = fork() ) {
-
- # finally, allow ^C on the parent process to terminate
- # the children.
- waitpid( $pid, 0 );
- exit;
- }
+When you C<kill -HUP> the server, it does its best to rexec itself.
+
+=item PIPE
+
+If the server detects a broken pipe while writing output to the client,
+it ignores the signal. Otherwise, a client closing the connection early
+could kill the server
- # do the exec. if $0 is not executable, try running it with $^X.
- exec {$0}( ( ( -x $0 ) ? () : ($^X) ), $0, @ARGV );
-};
+=back
+
+=head2 HTTP::Server::Simple->new($port)
+API call to start a new server. Does not actually start listening
+until you call C<-E<gt>run()>.
+
+=cut
sub new {
my ( $proto, $port ) = @_;
my $class = ref($proto) || $proto;
@@ -159,6 +150,28 @@
my $self = shift;
my $server = $self->net_server;
+ # Handle SIGHUP
+
+ local $SIG{CHLD} = 'IGNORE'; # reap child processes
+ local $SIG{HUP} = sub {
+ close HTTPDaemon;
+
+ # and then, on systems implementing fork(), we make sure
+ # we are running with a new pid, so another -HUP will still
+ # work on the new process.
+ require Config;
+ if ( $Config::Config{d_fork} and my $pid = fork() ) {
+
+ # finally, allow ^C on the parent process to terminate
+ # the children.
+ waitpid( $pid, 0 );
+ exit;
+ }
+
+ # do the exec. if $0 is not executable, try running it with $^X.
+ exec {$0}( ( ( -x $0 ) ? () : ($^X) ), $0, @ARGV );
+ };
+
# $pkg is generated anew for each invocation to "run"
# Just so we can use different net_server() implementations
# in different runs.
More information about the Rt-commit
mailing list