AnyEvent-HTTPD
view release on metacpan or search on metacpan
- removed bogus API stuff like ::Appgets or the weird
form and response handling. AnyEvent::HTTPD should be and
stay a simple HTTP server for simple purposes.
If you need further sugar, please write your own modules for
it. If you need anything ask me or look in the git repository
at http://git.ta-sa.org/AnyEvent-HTTPD.git
- added responded method to ::Request.
- stop_request now also stops further handling of the request
after the 'request' event.
- added 'request_timeout's
- added keep-alive support (for HTTP 1.0) (thanks to Andrey Smirnov).
0.04 Sun Dec 28 15:48:28 CET 2008
- removed TCP* classes and using AnyEvent::Handle instead.
- added size and maxlength args to the C<entry> function in Appgets
- changed the API to actually call the events for all path segments
of an URL. also removed the ugly '/' => '_' mapping for the path
seperators. Sorry for any breakage in your code ;-/
- removed Perl 5.10 dependency.
0.03 Tue Apr 15 12:57:10 CEST 2008
lib/AnyEvent/HTTPD.pm
samples/simple_example
samples/bshttp.png
samples/second_example
samples/delayed_example
samples/delayed_2_example
samples/large_response_example
t/00-load.t
t/01_basic_request.t
t/02_simple_requests.t
t/03_keep_alive.t
t/04_param.t
t/05_mp_param.t
t/06_long_resp.t
t/07_param_semicolon.t
t/10_allowed_methods.t
t/11_denied_methods.t
t/12_head_no_body.t
t/14_header_unset.t
META.yml Module meta-data (added by MakeMaker)
improve the HTTP support and send in patches!
The documentation is currently only the source code, but next versions
of this module will be better documented hopefully. See also the
"samples/" directory in the AnyEvent::HTTPD distribution for basic
starting points.
FEATURES
* support for GET and POST requests.
* support for HTTP 1.0 keep-alive.
* processing of "x-www-form-urlencoded" and "multipart/form-data"
("multipart/mixed") encoded form parameters.
* support for streaming responses.
* with version 0.8 no more dependend on LWP for HTTP::Date.
* (limited) support for SSL
* CPAN Ratings
<http://cpanratings.perl.org/d/AnyEvent-HTTPD>
* Search CPAN
<http://search.cpan.org/dist/AnyEvent-HTTPD>
ACKNOWLEDGEMENTS
Andrey Smirnov - for keep-alive patches.
Pedro Melo - for valuable input in general and patches.
Nicholas Harteau - patch for ';' pair separator support,
patch for allowed_methods support
Chris Kastorff - patch for making default headers removable
and more fault tolerant w.r.t. case.
Mons Anderson - Optimizing the regexes in L<AnyEvent::HTTPD::HTTPConnection>
and adding the C<backlog> option to L<AnyEvent::HTTPD>.
COPYRIGHT & LICENSE
Copyright 2008-2011 Robin Redeker, all rights reserved.
lib/AnyEvent/HTTPD.pm view on Meta::CPAN
The documentation is currently only the source code, but next versions of this
module will be better documented hopefully. See also the C<samples/> directory
in the L<AnyEvent::HTTPD> distribution for basic starting points.
=head1 FEATURES
=over 4
=item * support for GET and POST requests.
=item * support for HTTP 1.0 keep-alive.
=item * processing of C<x-www-form-urlencoded> and C<multipart/form-data> (C<multipart/mixed>) encoded form parameters.
=item * support for streaming responses.
=item * with version 0.8 no more dependend on L<LWP> for L<HTTP::Date>.
=item * (limited) support for SSL
=back
lib/AnyEvent/HTTPD.pm view on Meta::CPAN
L<http://cpanratings.perl.org/d/AnyEvent-HTTPD>
=item * Search CPAN
L<http://search.cpan.org/dist/AnyEvent-HTTPD>
=back
=head1 ACKNOWLEDGEMENTS
Andrey Smirnov - for keep-alive patches.
Pedro Melo - for valuable input in general and patches.
Nicholas Harteau - patch for ';' pair separator support,
patch for allowed_methods support
Chris Kastorff - patch for making default headers removable
and more fault tolerant w.r.t. case.
Mons Anderson - Optimizing the regexes in L<AnyEvent::HTTPD::HTTPConnection>
and adding the C<backlog> option to L<AnyEvent::HTTPD>.
=head1 COPYRIGHT & LICENSE
lib/AnyEvent/HTTPD/HTTPConnection.pm view on Meta::CPAN
sub response_done {
my ($self) = @_;
(delete $self->{transfer_cb})->() if $self->{transfer_cb};
# sometimes a response might be written after connection is already dead:
return unless defined ($self->{hdl}) && !$self->{disconnected};
$self->{hdl}->on_drain; # clear any drain handlers
if ($self->{keep_alive}) {
$self->push_header_line;
} else {
$self->{hdl}->on_drain (sub { $self->do_disconnect });
}
}
our @DoW = qw(Sun Mon Tue Wed Thu Fri Sat);
our @MoY = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
our %MoY;
lib/AnyEvent/HTTPD/HTTPConnection.pm view on Meta::CPAN
return unless $self->{hdl};
my $res = "HTTP/1.0 $code $msg\015\012";
header_set ($hdr, 'Date' => _time_to_http_date time)
unless header_exists ($hdr, 'Date');
header_set ($hdr, 'Expires' => header_get ($hdr, 'Date'))
unless header_exists ($hdr, 'Expires');
header_set ($hdr, 'Cache-Control' => "max-age=0")
unless header_exists ($hdr, 'Cache-Control');
header_set ($hdr, 'Connection' =>
($self->{keep_alive} ? 'Keep-Alive' : 'close'));
header_set ($hdr, 'Content-Length' => length "$content")
unless header_exists ($hdr, 'Content-Length')
|| ref $content;
unless (defined header_get ($hdr, 'Content-Length')) {
# keep alive with no content length will NOT work.
delete $self->{keep_alive};
header_set ($hdr, 'Connection' => 'close');
}
while (my ($h, $v) = each %$hdr) {
next unless defined $v;
$res .= "$h: $v\015\012";
}
$res .= "\015\012";
lib/AnyEvent/HTTPD/HTTPConnection.pm view on Meta::CPAN
if (/^\s*boundary\s*=\s*(.*?)\s*$/o) {
$bound = _unquote ($1);
}
}
($c, $bound)
}
sub handle_request {
my ($self, $method, $uri, $hdr, $cont) = @_;
$self->{keep_alive} = ($hdr->{connection} =~ /keep-alive/io);
my ($ctype, $bound) = _content_type_boundary ($hdr->{'content-type'});
if ($ctype eq 'multipart/form-data') {
$cont = $self->decode_multipart ($cont, $bound);
} elsif ($ctype =~ /x-www-form-urlencoded/o) {
$cont = parse_urlencoded ($cont);
}
lib/AnyEvent/HTTPD/HTTPConnection.pm view on Meta::CPAN
if ($vm >= 2) {
$self->error (506, "http protocol version not supported");
return;
}
$self->{last_header} = [$meth, $url];
$self->push_header;
} elsif ($line eq '') {
# ignore empty lines before requests, this prevents
# browser bugs w.r.t. keep-alive (according to marc lehmann).
$self->push_header_line;
} else {
$self->error (400 => 'bad request');
}
});
}
sub do_disconnect {
my ($self, $err) = @_;
t/14_header_unset.t view on Meta::CPAN
my $c3 = AnyEvent::HTTPD::Util::test_connect ('127.0.0.1', $h->port,
"GET\040/header-override-uppercase\040HTTP/1.0\015\012\015\012");
my $r1 = $c1->recv;
my $r2 = $c2->recv;
my $r3 = $c3->recv;
unlike ($r1, qr/^expires:/im, "Can unset Expires header");
unlike ($r1, qr/^cache-control:/im, "Can unset Cache-Control header");
unlike ($r1, qr/^content-length:/im, "Can unset Content-Length header");
unlike ($r1, qr/^connection:\s*close$/im,
"Unsetting Content-Length implies no keep-alive");
like ($r2, qr/^cache-control:\s*nonsensical/im,
"Cache-Control set with lowercase gets through");
unlike ($r2, qr/^cache-control:\s*max-age/im,
"Cache-Control set with lowercase removes default header");
like ($r3, qr/^cache-control:\s*nonsensical/im,
"Cache-Control set with uppercase gets through");
unlike ($r3, qr/^cache-control:\s*max-age/im,
"Cache-Control set with uppercase removes default header");
( run in 2.039 seconds using v1.01-cache-2.11-cpan-df04353d9ac )