AnyEvent-HTTPD
view release on metacpan or search on metacpan
lib/AnyEvent/HTTPD/Request.pm view on Meta::CPAN
package AnyEvent::HTTPD::Request;
use common::sense;
=head1 NAME
AnyEvent::HTTPD::Request - A web application request handle for L<AnyEvent::HTTPD>
=head1 DESCRIPTION
This is the request object as generated by L<AnyEvent::HTTPD> and given
in the request callbacks.
=head1 METHODS
=over 4
=cut
sub new {
my $this = shift;
my $class = ref($this) || $this;
my $self = { @_ };
bless $self, $class
}
=item B<url>
This method returns the URL of the current request as L<URI> object.
=cut
sub url {
my ($self) = @_;
my $url = $self->{url};
my $u = URI->new ($url);
$u
}
=item B<respond ([$res])>
C<$res> can be:
=over 4
=item * an array reference
Then the array reference has these elements:
my ($code, $message, $header_hash, $content) =
[200, 'ok', { 'Content-Type' => 'text/html' }, '<h1>Test</h1>' }]
You can remove most headers added by default (like C<Cache-Control>,
C<Expires>, and C<Content-Length>) by setting them to undef, like so:
$req->respond([
200, 'OK', {
'Content-Type' => 'text/html',
'Cache-Control' => 'max-age=3600',
'Expires' => undef,
},
'This data will be cached for one hour.'
]);
=item * a hash reference
If it was a hash reference the hash is first searched for the C<redirect>
key and if that key does not exist for the C<content> key.
The value for the C<redirect> key should contain the URL that you want to redirect
the request to.
( run in 1.430 second using v1.01-cache-2.11-cpan-140bd7fdf52 )