AnyEvent-REST-Server
view release on metacpan or search on metacpan
lib/AnyEvent/REST/Server.pm view on Meta::CPAN
$self->{connections}{$id}{version} = $3;
if ($self->{connections}{$id}{location} =~ /(.*)\/$/) {
$self->{connections}{$id}{location} = $1;
}
if ($self->can_handle("$self->{connections}{$id}{command} $self->{connections}{$id}{location}")) {
$self->read_http_header($id);
}
else {
$self->send_not_found($id);
}
}
);
}
sub read_http_header {
my ($self, $id) = @_;
$self->{connections}{$id}{handle}->push_read(
line => qr<\r?\n\r?\n>,
lib/AnyEvent/REST/Server.pm view on Meta::CPAN
};
my $response = 'HTTP/'.$self->{connections}{$id}{version}.' '.$code.' '.$HTTP_CODE_TEXT->{$code}.$HTTP_EOL;
$response .= "$_: $header->{$_}$HTTP_EOL" foreach (keys %$header);
$response .= $HTTP_EOL;
$response .= $body if $body;
$self->{connections}{$id}{handle}->push_write($response);
}
sub send_not_found {
shift->send(shift, 404, {}, '');
}
1;
( run in 0.247 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )