Skip to content

Commit

Permalink
documentation tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 12, 2013
1 parent c82b314 commit dc9b3a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
18 changes: 9 additions & 9 deletions lib/Mojo/UserAgent/Transactor.pm
Expand Up @@ -135,7 +135,7 @@ sub tx {
$req->headers->from_hash(shift) if ref $_[0] eq 'HASH';

# Generator
if (@_ >= 2) {
if (@_ > 1) {
return $tx unless my $generator = $self->generators->{shift()};
$self->$generator($tx, @_);
}
Expand Down Expand Up @@ -368,7 +368,7 @@ C<307> or C<308> redirect response if possible.
PUT => 'http://kraih.com' => {DNT => 1} => json => {a => 'b'});
Versatile general purpose L<Mojo::Transaction::HTTP> transaction builder for
requests.
requests, with support for generators.
# Inspect generated request
say $t->tx(GET => 'mojolicio.us' => {DNT => 1} => 'Bye!')->req->to_string;
Expand All @@ -381,22 +381,26 @@ requests.
my $tx = $t->tx(GET => 'http://mojolicio.us');
$tx->connection($sock);
# Use form generator with custom charset
my $tx = $t->tx(
PUT => 'http://kraih.com' => form => {a => 'b'} => charset => 'UTF-8');
# Multiple form values with the same name
my $tx = $t->tx(PUT => 'http://kraih.com' => form => {a => [qw(b c d)]});
# Multipart upload streamed from file
my $tx = $t->tx(
PUT => 'http://kraih.com' => form => {mytext => {file => '/foo.txt'}});
# Multipart upload (in memory)
# Multipart upload with in-memory content
my $tx = $t->tx(
POST => 'http://kraih.com' => form => {mytext => {content => 'lalala'}});
# Multiple files
# Upload multiple files
my $tx = $t->tx(POST => 'http://kraih.com' => form =>
{mytext => [{content => 'first'}, {content => 'second'}]});
# Part with filename and custom header
# Customized upload with filename and header
my $tx = $t->tx(POST => 'http://kraih.com' => form => {
myzip => {
file => Mojo::Asset::Memory->new->add_chunk('lalala'),
Expand All @@ -405,10 +409,6 @@ requests.
}
});
# Custom charset
my $tx = $t->tx(
PUT => 'http://kraih.com' => form => {a => 'b'} => charset => 'UTF-8');
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
3 changes: 1 addition & 2 deletions lib/Mojolicious/Command/cpanify.pm
Expand Up @@ -25,8 +25,7 @@ sub run {
die $self->usage unless my $file = shift @args;

my $tx = Mojo::UserAgent->new->detect_proxy->post(
"https://$user:$password\@pause.perl.org/pause/authenquery",
form => {
"https://$user:$password\@pause.perl.org/pause/authenquery" => form => {
HIDDENNAME => $user,
CAN_MULTIPART => 1,
pause99_add_uri_upload => basename($file),
Expand Down

0 comments on commit dc9b3a4

Please sign in to comment.