Skip to content

Commit

Permalink
added example for interrupting a user agent transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 1, 2014
1 parent 4d62346 commit ed1d91e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/Mojo/UserAgent.pm
Expand Up @@ -675,11 +675,20 @@ implements the following new ones.
Generate L<Mojo::Transaction::HTTP> object with
L<Mojo::UserAgent::Transactor/"tx">.
# Request with cookie
# Request with custom cookie
my $tx = $ua->build_tx(GET => 'example.com');
$tx->req->cookies({name => 'foo', value => 'bar'});
$ua->start($tx);
# Interrupt transaction by raising an error
my $tx = $ua->build_tx(GET => 'example.com');
$tx->res->on(progress => sub {
my $res = shift;
return unless my $server = $res->headers->server;
$res->error('Oh noes, it is IIS!') if $server =~ /IIS/;
});
$ua->start($tx);
=head2 build_websocket_tx
my $tx = $ua->build_websocket_tx('ws://example.com');
Expand Down

0 comments on commit ed1d91e

Please sign in to comment.