Catalyst-Engine-HTTP-Prefork
view release on metacpan or search on metacpan
lib/Catalyst/Engine/HTTP/Prefork.pm view on Meta::CPAN
$self->{client}->{inputbuf} =~ s/.*?$CRLF$CRLF//s;
return 1;
}
sub _http_error {
my ( $self, $code, $protocol, $reason ) = @_;
my $status = $code || 500;
my $message = status_message($status);
my $response = HTTP::Response->new( $status => $message );
$response->protocol( $protocol || 'HTTP/1.0' );
$response->content_type( 'text/plain' );
$response->header( Connection => 'close' );
$response->date( time() );
if ( !$reason ) {
$reason = $message;
}
my $msg = "$status $reason";
$response->content_length( length($msg) );
$response->content( $msg );
syswrite STDOUT, $response->as_string($CRLF);
}
1;
__END__
=head1 NAME
Catalyst::Engine::HTTP::Prefork - High-performance pre-forking Catalyst engine
=head1 SYNOPIS
CATALYST_ENGINE='HTTP::Prefork' script/yourapp_server.pl
=head1 DESCRIPTION
This engine is designed to run as a standalone Catalyst server, without
requiring the use of another web server. It's goals are high-performance,
HTTP/1.1 compliance, and robustness. It is also suitable for use as a
faster development server with support for automatic restarting.
This engine is designed to replace the L<Catalyst::Engine::HTTP::POE> engine,
which is now deprecated.
=head1 RESTART SUPPORT
This engine supports the same restart options as L<Catalyst::Engine::HTTP>.
The server may also be restarted by sending it a HUP signal.
=head1 HTTP/1.1 support
This engine fully supports the following HTTP/1.1 features:
=head2 Chunked Requests
Chunked body data is handled transparently by L<HTTP::Body>.
=head2 Chunked Responses
By setting the Transfer-Encoding header to 'chunked', you can indicate you
would like the response to be sent to the client as a chunked response. Also,
any responses without a content-length will be sent chunked.
=head2 Pipelined Requests
Browsers sending any number of pipelined requests will be handled properly.
=head2 Keep-Alive
Keep-alive is supported for both HTTP/1.1 (by default) and HTTP/1.0 (if a
Connection: keep-alive header is present in the request).
=head1 CUSTOMIZATION
Additional options may be passed to the engine by modifying
yourapp_server.pl to send additional items to the run() method.
=head2 min_servers
The minimum number of servers to keep running. Defaults to 5.
=head2 min_spare_servers
The minimum number of servers to have waiting for requests. Minimum and
maximum numbers should not be set too close to each other or the server will
fork and kill children too often. Defaults to 2.
=head2 max_spare_servers
The maximum number of servers to have waiting for requests. Defaults to 10.
=head2 max_servers
The maximum number of child servers to start. Defaults to 50.
=head2 max_requests
Restart a child after it has served this many requests. Defaults to 1000.
Note that setting this value to 0 will not cause the child to serve unlimited
requests. This is a limitation of Net::Server and may be fixed in a future
version.
=head2 restart_graceful
This enables Net::Server's leave_children_open_on_hup option. If set, the parent
will not attempt to close child processes if the parent receives a SIGHUP. Each
child will exit as soon as possible after processing the current request if any.
=head2 pidfile
This passes through to Net::Server's pid_file option. If set, the pidfile is
written to the path. Default is none. This file is not removed on server exit
=head2 background
This option passes through to Net::Server and also sets the 'setsid' option to
( run in 0.700 second using v1.01-cache-2.11-cpan-13bb782fe5a )