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;
}
More than 5 years have passed since last update.
HTTP::Request -> AnyEvent::HTTP -> HTTP::Response
Last updated at Posted at 2012-03-16
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme