Edited at

HTTP::Request -> AnyEvent::HTTP -> HTTP::Response

More than 5 years have passed since last update.

sub anyevent_request_cv {

my ($req, @args) = @_;

my $cv = AE::cv;
http_request(
$req->method,
$req->uri,
body => $req->content,
headers => {
map { ( $_ => $req->header($_) ) } $req->header_field_names
},
@args,
sub {
my ($body, $headers) = @_;
my ($code, $msg) = ( delete $headers->{Status}, delete $headers->{Reason} );
my $res = HTTP::Response->new($code, $msg, [ %$headers ], $body);
$cv->send($res);
}
);
return $cv;
}