AnyEvent::HTTP::ScopedClient - AnyEvent based https://github.com/technoweenie/node-scoped-http-client
version 0.0.5
my $client = AnyEvent::HTTP::ScopedClient->new('http://example.com'); $client->request('GET', sub { my ($body, $hdr) = @_; # $body is undef if error occured return if ( !$body || $hdr->{Status} !~ /^2/ ); # do something; }); # shorcut for GET $client->get(sub { my ($body, $hdr) = @_; # ... }); # Content-Type: application/x-www-form-urlencoded $client->post( { foo => 1, bar => 2 }, # note this. sub { my ($body, $hdr) = @_; # ... } ); # application/x-www-form-urlencoded post request $client->post( "foo=1&bar=2" # and note this. sub { my ($body, $hdr) = @_; # ... } ); # Content-Type: application/json use JSON::XS; $client->header('Content-Type', 'application/json') ->post( encode_json({ foo => 1 }), sub { my ($body, $hdr) = @_; # ... } ); $client->header('Accept', 'application/json') ->query({ key => 'value' }) ->query('key', 'value') ->get( sub { my ($body, $hdr) = @_; # ... } ); # headers at once $client->header({ Accept => '*/*', Authorization => 'Basic abcd' })->get( sub { my ($body, $hdr) = @_; # ... } );
AnyEvent::HTTP wrapper
https://github.com/technoweenie/node-scoped-http-client
Hyungsuk Hong <hshong@perl.kr>
This software is copyright (c) 2012 by Hyungsuk Hong.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install AnyEvent::HTTP::ScopedClient, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnyEvent::HTTP::ScopedClient
CPAN shell
perl -MCPAN -e shell install AnyEvent::HTTP::ScopedClient
For more information on module installation, please visit the detailed CPAN module installation guide.