Skip to content

Commit

Permalink
more diverse example headers
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 11, 2014
1 parent 175cc94 commit 6ee85f2
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 56 deletions.
53 changes: 29 additions & 24 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -645,11 +645,12 @@ implements the following new ones.
=head2 build_tx
my $tx = $ua->build_tx(GET => 'example.com');
my $tx = $ua->build_tx(PUT => 'http://example.com' => {DNT => 1} => 'Hi!');
my $tx = $ua->build_tx(
PUT => 'http://example.com' => {DNT => 1} => form => {a => 'b'});
PUT => 'http://example.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->build_tx(
PUT => 'http://example.com' => {DNT => 1} => json => {a => 'b'});
PUT => 'http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
my $tx = $ua->build_tx(
PUT => 'http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Generate L<Mojo::Transaction::HTTP> object with
L<Mojo::UserAgent::Transactor/"tx">.
Expand Down Expand Up @@ -685,11 +686,11 @@ L<Mojo::UserAgent::Transactor/"websocket">.
=head2 delete
my $tx = $ua->delete('example.com');
my $tx = $ua->delete('http://example.com' => {DNT => 1} => 'Hi!');
my $tx = $ua->delete('http://example.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->delete(
'http://example.com' => {DNT => 1} => form => {a => 'b'});
'http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
my $tx = $ua->delete(
'http://example.com' => {DNT => 1} => json => {a => 'b'});
'http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Perform blocking C<DELETE> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the same arguments as
Expand All @@ -705,9 +706,11 @@ append a callback to perform requests non-blocking.
=head2 get
my $tx = $ua->get('example.com');
my $tx = $ua->get('http://example.com' => {DNT => 1} => 'Hi!');
my $tx = $ua->get('http://example.com' => {DNT => 1} => form => {a => 'b'});
my $tx = $ua->get('http://example.com' => {DNT => 1} => json => {a => 'b'});
my $tx = $ua->get('http://example.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->get(
'http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
my $tx = $ua->get(
'http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Perform blocking C<GET> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the same arguments as
Expand All @@ -723,11 +726,11 @@ append a callback to perform requests non-blocking.
=head2 head
my $tx = $ua->head('example.com');
my $tx = $ua->head('http://example.com' => {DNT => 1} => 'Hi!');
my $tx = $ua->head('http://example.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->head(
'http://example.com' => {DNT => 1} => form => {a => 'b'});
'http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
my $tx = $ua->head(
'http://example.com' => {DNT => 1} => json => {a => 'b'});
'http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Perform blocking C<HEAD> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the same arguments as
Expand All @@ -743,11 +746,11 @@ append a callback to perform requests non-blocking.
=head2 options
my $tx = $ua->options('example.com');
my $tx = $ua->options('http://example.com' => {DNT => 1} => 'Hi!');
my $tx = $ua->options('http://example.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->options(
'http://example.com' => {DNT => 1} => form => {a => 'b'});
'http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
my $tx = $ua->options(
'http://example.com' => {DNT => 1} => json => {a => 'b'});
'http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Perform blocking C<OPTIONS> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the same arguments as
Expand All @@ -763,11 +766,11 @@ append a callback to perform requests non-blocking.
=head2 patch
my $tx = $ua->patch('example.com');
my $tx = $ua->patch('http://example.com' => {DNT => 1} => 'Hi!');
my $tx = $ua->patch('http://example.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->patch(
'http://example.com' => {DNT => 1} => form => {a => 'b'});
'http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
my $tx = $ua->patch(
'http://example.com' => {DNT => 1} => json => {a => 'b'});
'http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Perform blocking C<PATCH> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the same arguments as
Expand All @@ -783,11 +786,11 @@ append a callback to perform requests non-blocking.
=head2 post
my $tx = $ua->post('example.com');
my $tx = $ua->post('http://example.com' => {DNT => 1} => 'Hi!');
my $tx = $ua->post('http://example.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->post(
'http://example.com' => {DNT => 1} => form => {a => 'b'});
'http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
my $tx = $ua->post(
'http://example.com' => {DNT => 1} => json => {a => 'b'});
'http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Perform blocking C<POST> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the same arguments as
Expand All @@ -803,9 +806,11 @@ append a callback to perform requests non-blocking.
=head2 put
my $tx = $ua->put('example.com');
my $tx = $ua->put('http://example.com' => {DNT => 1} => 'Hi!');
my $tx = $ua->put('http://example.com' => {DNT => 1} => form => {a => 'b'});
my $tx = $ua->put('http://example.com' => {DNT => 1} => json => {a => 'b'});
my $tx = $ua->put('http://example.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->put(
'http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
my $tx = $ua->put(
'http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Perform blocking C<PUT> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the same arguments as
Expand Down
8 changes: 4 additions & 4 deletions lib/Mojo/UserAgent/Transactor.pm
Expand Up @@ -362,15 +362,15 @@ C<307> or C<308> redirect response if possible.
my $tx = $t->tx(GET => 'example.com');
my $tx = $t->tx(POST => 'http://example.com');
my $tx = $t->tx(GET => 'http://example.com' => {DNT => 1});
my $tx = $t->tx(GET => 'http://example.com' => {Accept => '*/*'});
my $tx = $t->tx(PUT => 'http://example.com' => 'Hi!');
my $tx = $t->tx(PUT => 'http://example.com' => form => {a => 'b'});
my $tx = $t->tx(PUT => 'http://example.com' => json => {a => 'b'});
my $tx = $t->tx(POST => 'http://example.com' => {DNT => 1} => 'Hi!');
my $tx = $t->tx(POST => 'http://example.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $t->tx(
PUT => 'http://example.com' => {DNT => 1} => form => {a => 'b'});
PUT => 'http://example.com' => {Accept => '*/*'} => form => {a => 'b'});
my $tx = $t->tx(
PUT => 'http://example.com' => {DNT => 1} => json => {a => 'b'});
PUT => 'http://example.com' => {Accept => '*/*'} => json => {a => 'b'});
Versatile general purpose L<Mojo::Transaction::HTTP> transaction builder for
requests, with support for L</"GENERATORS">.
Expand Down
42 changes: 21 additions & 21 deletions lib/Test/Mojo.pm
Expand Up @@ -591,9 +591,9 @@ Opposite of L</"content_type_like">.
=head2 delete_ok
$t = $t->delete_ok('/foo');
$t = $t->delete_ok('/foo' => {DNT => 1} => 'Hi!');
$t = $t->delete_ok('/foo' => {DNT => 1} => form => {a => 'b'});
$t = $t->delete_ok('/foo' => {DNT => 1} => json => {a => 'b'});
$t = $t->delete_ok('/foo' => {Accept => '*/*'} => 'Hi!');
$t = $t->delete_ok('/foo' => {Accept => '*/*'} => form => {a => 'b'});
$t = $t->delete_ok('/foo' => {Accept => '*/*'} => json => {a => 'b'});
Perform a C<DELETE> request and check for transport errors, takes the same
arguments as L<Mojo::UserAgent/"delete">, except for the callback.
Expand Down Expand Up @@ -630,9 +630,9 @@ Wait for WebSocket connection to be closed gracefully and check status.
=head2 get_ok
$t = $t->get_ok('/foo');
$t = $t->get_ok('/foo' => {DNT => 1} => 'Hi!');
$t = $t->get_ok('/foo' => {DNT => 1} => form => {a => 'b'});
$t = $t->get_ok('/foo' => {DNT => 1} => json => {a => 'b'});
$t = $t->get_ok('/foo' => {Accept => '*/*'} => 'Hi!');
$t = $t->get_ok('/foo' => {Accept => '*/*'} => form => {a => 'b'});
$t = $t->get_ok('/foo' => {Accept => '*/*'} => json => {a => 'b'});
Perform a C<GET> request and check for transport errors, takes the same
arguments as L<Mojo::UserAgent/"get">, except for the callback.
Expand All @@ -643,9 +643,9 @@ arguments as L<Mojo::UserAgent/"get">, except for the callback.
=head2 head_ok
$t = $t->head_ok('/foo');
$t = $t->head_ok('/foo' => {DNT => 1} => 'Hi!');
$t = $t->head_ok('/foo' => {DNT => 1} => form => {a => 'b'});
$t = $t->head_ok('/foo' => {DNT => 1} => json => {a => 'b'});
$t = $t->head_ok('/foo' => {Accept => '*/*'} => 'Hi!');
$t = $t->head_ok('/foo' => {Accept => '*/*'} => form => {a => 'b'});
$t = $t->head_ok('/foo' => {Accept => '*/*'} => json => {a => 'b'});
Perform a C<HEAD> request and check for transport errors, takes the same
arguments as L<Mojo::UserAgent/"head">, except for the callback.
Expand Down Expand Up @@ -818,9 +818,9 @@ Construct a new L<Test::Mojo> object.
=head2 options_ok
$t = $t->options_ok('/foo');
$t = $t->options_ok('/foo' => {DNT => 1} => 'Hi!');
$t = $t->options_ok('/foo' => {DNT => 1} => form => {a => 'b'});
$t = $t->options_ok('/foo' => {DNT => 1} => json => {a => 'b'});
$t = $t->options_ok('/foo' => {Accept => '*/*'} => 'Hi!');
$t = $t->options_ok('/foo' => {Accept => '*/*'} => form => {a => 'b'});
$t = $t->options_ok('/foo' => {Accept => '*/*'} => json => {a => 'b'});
Perform a C<OPTIONS> request and check for transport errors, takes the same
arguments as L<Mojo::UserAgent/"options">, except for the callback.
Expand All @@ -838,19 +838,19 @@ Invoke callback if the value of L</"success"> is false.
=head2 patch_ok
$t = $t->patch_ok('/foo');
$t = $t->patch_ok('/foo' => {DNT => 1} => 'Hi!');
$t = $t->patch_ok('/foo' => {DNT => 1} => form => {a => 'b'});
$t = $t->patch_ok('/foo' => {DNT => 1} => json => {a => 'b'});
$t = $t->patch_ok('/foo' => {Accept => '*/*'} => 'Hi!');
$t = $t->patch_ok('/foo' => {Accept => '*/*'} => form => {a => 'b'});
$t = $t->patch_ok('/foo' => {Accept => '*/*'} => json => {a => 'b'});
Perform a C<PATCH> request and check for transport errors, takes the same
arguments as L<Mojo::UserAgent/"patch">, except for the callback.
=head2 post_ok
$t = $t->post_ok('/foo');
$t = $t->post_ok('/foo' => {DNT => 1} => 'Hi!');
$t = $t->post_ok('/foo' => {DNT => 1} => form => {a => 'b'});
$t = $t->post_ok('/foo' => {DNT => 1} => json => {a => 'b'});
$t = $t->post_ok('/foo' => {Accept => '*/*'} => 'Hi!');
$t = $t->post_ok('/foo' => {Accept => '*/*'} => form => {a => 'b'});
$t = $t->post_ok('/foo' => {Accept => '*/*'} => json => {a => 'b'});
Perform a C<POST> request and check for transport errors, takes the same
arguments as L<Mojo::UserAgent/"post">, except for the callback.
Expand All @@ -867,9 +867,9 @@ arguments as L<Mojo::UserAgent/"post">, except for the callback.
=head2 put_ok
$t = $t->put_ok('/foo');
$t = $t->put_ok('/foo' => {DNT => 1} => 'Hi!');
$t = $t->put_ok('/foo' => {DNT => 1} => form => {a => 'b'});
$t = $t->put_ok('/foo' => {DNT => 1} => json => {a => 'b'});
$t = $t->put_ok('/foo' => {Accept => '*/*'} => 'Hi!');
$t = $t->put_ok('/foo' => {Accept => '*/*'} => form => {a => 'b'});
$t = $t->put_ok('/foo' => {Accept => '*/*'} => json => {a => 'b'});
Perform a C<PUT> request and check for transport errors, takes the same
arguments as L<Mojo::UserAgent/"put">, except for the callback.
Expand Down
14 changes: 7 additions & 7 deletions lib/ojo.pm
Expand Up @@ -113,15 +113,15 @@ Turn list into a L<Mojo::Collection> object.
=head2 d
my $res = d('example.com');
my $res = d('http://example.com' => {DNT => 1} => 'Hi!');
my $res = d('http://example.com' => {Accept => '*/*'} => 'Hi!');
Perform C<DELETE> request with L<Mojo::UserAgent/"delete"> and return
resulting L<Mojo::Message::Response> object.
=head2 g
my $res = g('example.com');
my $res = g('http://example.com' => {DNT => 1} => 'Hi!');
my $res = g('http://example.com' => {Accept => '*/*'} => 'Hi!');
Perform C<GET> request with L<Mojo::UserAgent/"get"> and return resulting
L<Mojo::Message::Response> object.
Expand All @@ -131,7 +131,7 @@ L<Mojo::Message::Response> object.
=head2 h
my $res = h('example.com');
my $res = h('http://example.com' => {DNT => 1} => 'Hi!');
my $res = h('http://example.com' => {Accept => '*/*'} => 'Hi!');
Perform C<HEAD> request with L<Mojo::UserAgent/"head"> and return resulting
L<Mojo::Message::Response> object.
Expand Down Expand Up @@ -159,15 +159,15 @@ iterations, which defaults to C<1>.
=head2 o
my $res = o('example.com');
my $res = o('http://example.com' => {DNT => 1} => 'Hi!');
my $res = o('http://example.com' => {Accept => '*/*'} => 'Hi!');
Perform C<OPTIONS> request with L<Mojo::UserAgent/"options"> and return
resulting L<Mojo::Message::Response> object.
=head2 p
my $res = p('example.com');
my $res = p('http://example.com' => {DNT => 1} => 'Hi!');
my $res = p('http://example.com' => {Accept => '*/*'} => 'Hi!');
Perform C<POST> request with L<Mojo::UserAgent/"post"> and return resulting
L<Mojo::Message::Response> object.
Expand All @@ -183,15 +183,15 @@ Dump a Perl data structure with L<Mojo::Util/"dumper">.
=head2 t
my $res = t('example.com');
my $res = t('http://example.com' => {DNT => 1} => 'Hi!');
my $res = t('http://example.com' => {Accept => '*/*'} => 'Hi!');
Perform C<PATCH> request with L<Mojo::UserAgent/"patch"> and return resulting
L<Mojo::Message::Response> object.
=head2 u
my $res = u('example.com');
my $res = u('http://example.com' => {DNT => 1} => 'Hi!');
my $res = u('http://example.com' => {Accept => '*/*'} => 'Hi!');
Perform C<PUT> request with L<Mojo::UserAgent/"put"> and return resulting
L<Mojo::Message::Response> object.
Expand Down

0 comments on commit 6ee85f2

Please sign in to comment.