Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added request with cookie example
  • Loading branch information
kraih committed Apr 19, 2012
1 parent 97eae38 commit 8076a9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 10 additions & 0 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -824,13 +824,23 @@ Get absolute L<Mojo::URL> object for C<app> and switch protocol if necessary.
Alias for L<Mojo::UserAgent::Transactor/"form">.
# Streaming multipart file upload
my $tx
= $ua->build_form_tx('mojolicio.us' => {fun => {file => '/etc/passwd'}});
$ua->start($tx);
=head2 C<build_tx>
my $tx = $ua->build_tx(GET => 'kraih.com');
my $tx = $ua->build_tx(PUT => 'http://kraih.com' => {DNT => 1} => 'Hi!');
Alias for L<Mojo::UserAgent::Transactor/"tx">.
# Request with cookie
my $tx = $ua->build_tx(GET => 'kraih.com');
$tx->req->cookies({name => 'foo', value => 'bar'});
$ua->start($tx);
=head2 C<build_websocket_tx>
my $tx = $ua->build_websocket_tx('ws://localhost:3000');
Expand Down
6 changes: 0 additions & 6 deletions lib/Mojo/UserAgent/Transactor.pm
Expand Up @@ -300,10 +300,6 @@ data.
# Inspect generated request
say $t->form('mojolicio.us' => {a => [1, 2, 3]})->req->to_string;
# Streaming multipart file upload
my $tx = $t->form('mojolicio.us' => {fun => {file => '/etc/passwd'}});
$ua->start($tx);
While the "multipart/form-data" content type will be automatically used
instead of "application/x-www-form-urlencoded" when necessary, you can also
enforce it by setting the header manually.
Expand Down Expand Up @@ -351,12 +347,10 @@ Versatile general purpose L<Mojo::Transaction::HTTP> builder for requests.
# Streaming response
my $tx = $t->tx(GET => 'http://mojolicio.us');
$tx->res->body(sub { say $_[1] });
$ua->start($tx);
# Custom socket
my $tx = $t->tx(GET => 'http://mojolicio.us');
$tx->connection($sock);
$ua->start($tx);
=head2 C<websocket>
Expand Down

0 comments on commit 8076a9c

Please sign in to comment.