
MojoX::UserAgent::Transaction - Basic building block of MojoX::UserAgent, encapsulates a single HTTP exchange.

my $tx = MojoX::UserAgent::Transaction->new(
{ url => 'http://www.some.host.com/bla/',
method => 'POST',
ua => $ua,
id => '123456',
headers => {
'Expect' => '100-continue',
'Content-Type' => 'text/plain'
},
body => 'Hello!',
callback => sub {
my ($ua, $tx) = @_;
ok(!$tx->has_error, 'Completed');
is($tx->id, '123456', 'Request ID');
is($tx->res->code, 200, 'Status 200');
}
}
};
$ua->spool($tx);

A subclass of Mojo::Transaction::Single, this class simply adds the few extra elements that are needed by MojoX::UserAgent.

This class inherits all the attributes of Mojo::Transaction::Single, and adds the following.
done_cbThe subroutine that will be called once the transaction is completed. When invoked, this sub is passed two arguments: the UserAgent object that performed the transaction and the transaction itself.
hopsThe number of hops (ie redirects) that this transaction has gone through.
idAn optional transaction identifier. Not used internally by the class, but preserved across redirects and accessible to the callback.
original_reqIf the transaction is redirected, this holds the original request object.
uaA pointer back to the MojoX::UserAgent to which this transaction was spooled.

MojoX::UserAgent::Transaction inherits all methods from Mojo::Transaction::Single and implements the following new ones.
newConstructor that accepts a reference to a hash of named arguments. This hash must contain the following key/value pairs:
It may also contain any/all of the following:
client_connectCalled when the transaction is about to be sent out, this method is used to add the User-Agent and request cookies to the outgoing request.