NAME

Mojo::Transactor - Transaction Builder

SYNOPSIS

use Mojo::Transactor;

my $t  = Mojo::Transactor->new;
my $tx = $t->tx(GET => 'http://mojolicio.us');

DESCRIPTION

Mojo::Transactor is the request building framework used by Mojo::UserAgent. Note that this module is EXPERIMENTAL and might change without warning!

METHODS

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

form

my $tx = $t->form('http://kraih.com/foo' => {test => 123});
my $tx = $t->form(
  'http://kraih.com/foo',
  'UTF-8',
  {test => 123}
);
my $tx = $t->form(
  'http://kraih.com/foo',
  {test => 123},
  {Accept => '*/*'}
);
my $tx = $t->form(
  'http://kraih.com/foo',
  'UTF-8',
  {test => 123},
  {Accept => '*/*'}
);
my $tx = $t->form(
  'http://kraih.com/foo',
  {file => {file => '/foo/bar.txt'}}
);
my $tx = $t->form(
  'http://kraih.com/foo',
  {file => {content => 'lalala'}}
);
my $tx = $t->form(
  'http://kraih.com/foo',
  {myzip => {file => $asset, filename => 'foo.zip'}}
);

Versatile Mojo::Transaction::HTTP builder for form requests.

my $tx = $t->form('http://kraih.com/foo' => {test => 123});
$tx->res->body(sub { print $_[1] });
$ua->start($tx);

peer

my ($scheme, $host, $port) = $t->peer($tx);

Actual peer for transaction.

proxy_connect

my $tx = $t->proxy_connect($old);

Build Mojo::Transaction::HTTP proxy connect request for transaction.

redirect

my $tx = $t->redirect($old);

Build Mojo::Transaction::HTTP followup request for redirect response.

tx

my $tx = $t->tx(GET => 'mojolicio.us');
my $tx = $t->tx(POST => 'http://mojolicio.us');
my $tx = $t->tx(GET => 'http://kraih.com' => {Accept => '*/*'});
my $tx = $t->tx(
  POST => 'http://kraih.com' => {{Accept => '*/*'} => 'Hi!'
);

Versatile general purpose Mojo::Transaction::HTTP builder for requests.

# Streaming response
my $tx = $t->tx(GET => 'http://mojolicio.us');
$tx->res->body(sub { print $_[1] });
$ua->start($tx);

# Custom socket
my $tx = $t->tx(GET => 'http://mojolicio.us');
$tx->connection($socket);
$ua->start($tx);

websocket

my $tx = $t->websocket('ws://localhost:3000');

Versatile Mojo::Transaction::WebSocket builder for WebSocket handshake requests.

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicio.us.