AnyEvent::HTTP::ScopedClient(3pm)

AnyEvent::HTTP::ScopedClient3pm

Anyevent based <https://github.com/technoweenie/node-scoped-http-client>

Usage

    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) = @_;
            # ...
        }
    );

Version

version 0.0.5

Overview

AnyEvent::HTTP wrapper

Releases

6 releases since Debian 8 (Jessie); the text changed 2 times.

  1. 8
  2. 9–11
  3. 12–13

Author

Hyungsuk Hong <[email protected]>

From libanyevent-http-scopedclient-perl 0.0.5-3 in Debian 13 (Trixie). Parsed by carta from the page's man source.