NAME

Mojo::Client - Client

SYNOPSIS

use Mojo::Client;

my $client = Mojo::Client->new;
$client->get(
    'http://kraih.com' => sub {
        my ($self, $tx) = @_;
        print $tx->res->code;
    }
)->process;

DESCRIPTION

Mojo::Client is a full featured async io HTTP 1.1 client.

ATTRIBUTES

Mojo::Client implements the following attributes.

app

my $app = $client->app;
$client = $client->app(Mojolicious::Lite->new);

continue_timeout

my $timeout = $client->continue_timeout;
$client     = $client->continue_timeout(5);

default_cb

my $cb  = $client->default_cb;
$client = $client->default_cb(sub {...});

ioloop

my $loop = $client->ioloop;
$client  = $client->ioloop(Mojo::IOLoop->new);

keep_alive_timeout

my $keep_alive_timeout = $client->keep_alive_timeout;
$client                = $client->keep_alive_timeout(15);

max_keep_alive_connections

my $max_keep_alive_connections = $client->max_keep_alive_connections;
$client                        = $client->max_keep_alive_connections(5);

METHODS

Mojo::Client inherits all methods from Mojo::Base and implements the following new ones.

new

my $client = Mojo::Client->new;

delete

$client = $client->delete('http://kraih.com' => sub {...});
$client = $client->delete(
  'http://kraih.com' => (Connection => 'close') => sub {...}
);

get

$client = $client->get('http://kraih.com' => sub {...});
$client = $client->get(
  'http://kraih.com' => (Connection => 'close') => sub {...}
);
$client = $client->head('http://kraih.com' => sub {...});
$client = $client->head(
  'http://kraih.com' => (Connection => 'close') => sub {...}
);

post

$client = $client->post('http://kraih.com' => sub {...});
$client = $client->post(
  'http://kraih.com' => (Connection => 'close') => sub {...}
);

process

$client = $client->process;
$client = $client->process(@transactions);
$client = $client->process(@transactions => sub {...});

put

$client = $client->put('http://kraih.com' => sub {...});
$client = $client->put(
  'http://kraih.com' => (Connection => 'close') => sub {...}
);

queue

$client = $client->queue(@transactions);
$client = $client->queue(@transactions => sub {...});