AnyEvent-HTTPD
view release on metacpan or search on metacpan
host => $host
The TCP address of the HTTP server will listen on. Usually
0.0.0.0 (the default), for a public server, or 127.0.0.1 for a
local server.
port => $port
The TCP port the HTTP server will listen on. If undefined some
free port will be used. You can get it via the "port" method.
ssl => $tls_ctx
If this option is given the server will listen for a SSL/TLS
connection on the configured port. As $tls_ctx you can pass
anything that you can pass as "tls_ctx" to an AnyEvent::Handle
object.
Example:
my $httpd =
AnyEvent::HTTPD->new (
port => 443,
ssl => { cert_file => "/path/to/my/server_cert_and_key.pem" }
);
Or:
my $httpd =
AnyEvent::HTTPD->new (
port => 443,
ssl => AnyEvent::TLS->new (...),
);
request_timeout => $seconds
This will set the request timeout for connections. The default
value is 60 seconds.
backlog => $int
The backlog argument defines the maximum length the queue of
pending connections may grow to. The real maximum queue length
will be 1.5 times more than the value specified in the backlog
lib/AnyEvent/HTTPD.pm view on Meta::CPAN
=item host => $host
The TCP address of the HTTP server will listen on. Usually 0.0.0.0 (the
default), for a public server, or 127.0.0.1 for a local server.
=item port => $port
The TCP port the HTTP server will listen on. If undefined some
free port will be used. You can get it via the C<port> method.
=item ssl => $tls_ctx
If this option is given the server will listen for a SSL/TLS connection on the
configured port. As C<$tls_ctx> you can pass anything that you can pass as
C<tls_ctx> to an L<AnyEvent::Handle> object.
Example:
my $httpd =
AnyEvent::HTTPD->new (
port => 443,
ssl => { cert_file => "/path/to/my/server_cert_and_key.pem" }
);
Or:
my $httpd =
AnyEvent::HTTPD->new (
port => 443,
ssl => AnyEvent::TLS->new (...),
);
=item request_timeout => $seconds
This will set the request timeout for connections.
The default value is 60 seconds.
=item backlog => $int
The backlog argument defines the maximum length the queue of pending
lib/AnyEvent/HTTPD/HTTPConnection.pm view on Meta::CPAN
bless $self, $class;
$self->{request_timeout} = 60
unless defined $self->{request_timeout};
$self->{hdl} =
AnyEvent::Handle->new (
fh => $self->{fh},
on_eof => sub { $self->do_disconnect },
on_error => sub { $self->do_disconnect ("Error: $!") },
($self->{ssl}
? (tls => "accept", tls_ctx => $self->{ssl})
: ()),
);
$self->push_header_line;
return $self
}
sub error {
my ($self, $code, $msg, $hdr, $content) = @_;
lib/AnyEvent/HTTPD/HTTPServer.pm view on Meta::CPAN
sub allowed_methods { $_[0]->{allowed_methods} }
sub accept_connection {
my ($self, $fh, $h, $p) = @_;
my $htc =
$self->{connection_class}->new (
fh => $fh,
request_timeout => $self->{request_timeout},
allowed_methods => $self->{allowed_methods},
ssl => $self->{ssl},
host => $h,
port => $p);
$self->{handles}->{$htc} = $htc;
weaken $self;
$htc->reg_cb (disconnect => sub {
if (defined $self) {
delete $self->{handles}->{$_[0]};
( run in 0.534 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )