AnyEvent-HTTP-ScopedClient
view release on metacpan or search on metacpan
$client->post(
"foo=1&bar=2" # and note this.
sub {
my ($body, $hdr) = @_; # $body is undef if error occured
return if ( !$body || !$hdr->{Status} =~ /^2/ );
# do something;
}
);
# Content-Type: application/json
use JSON::XS;
$client->header('Content-Type', 'application/json')
->post(
encode_json({ foo => 1 }),
sub {
my ($body, $hdr) = @_; # $body is undef if error occured
return if ( !$body || !$hdr->{Status} =~ /^2/ );
# do something;
}
);
lib/AnyEvent/HTTP/ScopedClient.pm view on Meta::CPAN
# 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')
( run in 0.311 second using v1.01-cache-2.11-cpan-4d50c553e7e )