Skip to content

Commit

Permalink
use DNT header instead of Accept for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 25, 2012
1 parent 2c534ca commit 7998c53
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 54 deletions.
42 changes: 16 additions & 26 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -840,34 +840,29 @@ Get absolute L<Mojo::URL> object for C<app> and switch protocol if necessary.
=head2 C<build_form_tx>
my $tx = $ua->build_form_tx('http://kraih.com' => {a => 'b'});
my $tx = $ua->build_form_tx(
'http://kraih.com',
'UTF-8',
{a => 'b'},
{Accept => '*/*'}
);
my $tx = $ua->build_form_tx('kraih.com' => {a => 'b'});
my $tx = $ua->build_form_tx('kraih.com', 'UTF-8', {a => 'b'}, {DNT => 1});
Alias for L<Mojo::UserAgent::Transactor/"form">.
=head2 C<build_tx>
my $tx = $ua->build_tx(GET => 'kraih.com');
my $tx = $ua->build_tx(PUT => 'kraih.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->build_tx(PUT => 'kraih.com' => {DNT => 1} => 'Hi!');
Alias for L<Mojo::UserAgent::Transactor/"tx">.
=head2 C<build_websocket_tx>
my $tx = $ua->build_websocket_tx('ws://localhost');
my $tx = $ua->build_websocket_tx('ws://localhost' => {Accept => '*/*'});
my $tx = $ua->build_websocket_tx('ws://localhost:3000');
my $tx = $ua->build_websocket_tx('ws://localhost:3000' => {DNT => 1});
Alias for L<Mojo::UserAgent::Transactor/"websocket">.
=head2 C<delete>
my $tx = $ua->delete('http://kraih.com');
my $tx = $ua->delete('http://kraih.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->delete('http://kraih.com' => {DNT => 1} => 'Hi!');
Perform blocking HTTP C<DELETE> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the exact same arguments as
Expand All @@ -891,7 +886,7 @@ proxy detection can be enabled with the C<MOJO_PROXY> environment variable.
=head2 C<get>
my $tx = $ua->get('http://kraih.com');
my $tx = $ua->get('http://kraih.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->get('http://kraih.com' => {DNT => 1} => 'Hi!');
Perform blocking HTTP C<GET> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the exact same arguments as
Expand All @@ -907,7 +902,7 @@ append a callback to perform requests non-blocking.
=head2 C<head>
my $tx = $ua->head('http://kraih.com');
my $tx = $ua->head('http://kraih.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->head('http://kraih.com' => {DNT => 1} => 'Hi!');
Perform blocking HTTP C<HEAD> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the exact same arguments as
Expand All @@ -929,7 +924,7 @@ Check if request for domain would use a proxy server.
=head2 C<options>
my $tx = $ua->options('http://kraih.com');
my $tx = $ua->options('http://kraih.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->options('http://kraih.com' => {DNT => 1} => 'Hi!');
Perform blocking HTTP C<OPTIONS> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the exact same arguments as
Expand All @@ -945,7 +940,7 @@ append a callback to perform requests non-blocking.
=head2 C<patch>
my $tx = $ua->patch('http://kraih.com');
my $tx = $ua->patch('http://kraih.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->patch('http://kraih.com' => {DNT => 1} => 'Hi!');
Perform blocking HTTP C<PATCH> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the exact same arguments as
Expand All @@ -961,7 +956,7 @@ append a callback to perform requests non-blocking.
=head2 C<post>
my $tx = $ua->post('http://kraih.com');
my $tx = $ua->post('http://kraih.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->post('http://kraih.com' => {DNT => 1} => 'Hi!');
Perform blocking HTTP C<POST> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the exact same arguments as
Expand All @@ -976,13 +971,8 @@ append a callback to perform requests non-blocking.
=head2 C<post_form>
my $tx = $ua->post_form('http://kraih.com' => {a => 'b'});
my $tx = $ua->post_form(
'http://kraih.com',
'UTF-8',
{a => 'b'},
{Accept => '*/*'}
);
my $tx = $ua->post_form('kraih.com' => {a => 'b'});
my $tx = $ua->post_form('kraih.com', 'UTF-8', {a => 'b'}, {DNT => 1});
Perform blocking HTTP C<POST> request with form data and return resulting
L<Mojo::Transaction::HTTP> object, takes the exact same arguments as
Expand All @@ -998,7 +988,7 @@ perform requests non-blocking.
=head2 C<put>
my $tx = $ua->put('http://kraih.com');
my $tx = $ua->put('http://kraih.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $ua->put('http://kraih.com' => {DNT => 1} => 'Hi!');
Perform blocking HTTP C<PUT> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the exact same arguments as
Expand Down Expand Up @@ -1026,8 +1016,8 @@ transactions non-blocking.
=head2 C<websocket>
$ua->websocket('ws://localhost' => sub {...});
$ua->websocket('ws://localhost' => {'Accept' => '*/*'} => sub {...});
$ua->websocket('ws://localhost:3000' => sub {...});
$ua->websocket('ws://localhost:3000' => {DNT => 1} => sub {...});
Open a non-blocking WebSocket connection with transparent handshake, takes
the exact same arguments as L<Mojo::UserAgent::Transactor/"websocket">.
Expand Down
17 changes: 6 additions & 11 deletions lib/Mojo/UserAgent/Transactor.pm
Expand Up @@ -285,14 +285,6 @@ implements the following new ones.
=head2 C<form>
my $tx = $t->form('http://kraih.com' => {a => 'b'});
my $tx = $t->form('http://kraih.com' => 'UTF-8' => {a => 'b'});
my $tx = $t->form('http://kraih.com' => {a => 'b'} => {Accept => '*/*'});
my $tx = $t->form(
'http://kraih.com',
'UTF-8',
{a => 'b'},
{Accept => '*/*'}
);
my $tx = $t->form('http://kraih.com' => {mytext => {file => '/foo.txt'}});
my $tx = $t->form('http://kraih.com' => {mytext => {content => 'lalala'}});
my $tx = $t->form('http://kraih.com' => {
Expand All @@ -301,6 +293,9 @@ implements the following new ones.
filename => 'foo.zip'
}
});
my $tx = $t->form('http://kraih.com' => 'UTF-8' => {a => 'b'});
my $tx = $t->form('http://kraih.com' => {a => 'b'} => {DNT => 1});
my $tx = $t->form('http://kraih.com', 'UTF-8', {a => 'b'}, {DNT => 1});
Versatile L<Mojo::Transaction::HTTP> builder for form requests.
Expand Down Expand Up @@ -342,9 +337,9 @@ or C<307> redirect response if possible.
my $tx = $t->tx(GET => 'kraih.com');
my $tx = $t->tx(POST => 'http://kraih.com');
my $tx = $t->tx(GET => 'http://kraih.com' => {Accept => '*/*'});
my $tx = $t->tx(GET => 'http://kraih.com' => {DNT => 1});
my $tx = $t->tx(PUT => 'http://kraih.com' => 'Hi!');
my $tx = $t->tx(POST => 'http://kraih.com' => {Accept => '*/*'} => 'Hi!');
my $tx = $t->tx(POST => 'http://kraih.com' => {DNT => 1} => 'Hi!');
Versatile general purpose L<Mojo::Transaction::HTTP> builder for requests.
Expand All @@ -361,7 +356,7 @@ Versatile general purpose L<Mojo::Transaction::HTTP> builder for requests.
=head2 C<websocket>
my $tx = $t->websocket('ws://localhost:3000');
my $tx = $t->websocket('ws://localhost:3000' => 'Accept' => '*/*');
my $tx = $t->websocket('ws://localhost:3000' => {DNT => 1});
Versatile L<Mojo::Transaction::WebSocket> builder for WebSocket handshake
requests.
Expand Down
18 changes: 9 additions & 9 deletions lib/Test/Mojo.pm
Expand Up @@ -505,7 +505,7 @@ Opposite of C<content_type_like>.
=head2 C<delete_ok>
$t = $t->delete_ok('/foo');
$t = $t->delete_ok('/foo' => {Accept => '*/*'} => 'Hi!');
$t = $t->delete_ok('/foo' => {DNT => 1} => 'Hi!');
Perform a C<DELETE> request and check for transport errors, takes the exact
same arguments as L<Mojo::UserAgent/"delete">.
Expand Down Expand Up @@ -535,15 +535,15 @@ Finish C<WebSocket> connection.
=head2 C<get_ok>
$t = $t->get_ok('/foo');
$t = $t->get_ok('/foo' => {Accept => '*/*'} => 'Hi!');
$t = $t->get_ok('/foo' => {DNT => 1} => 'Hi!');
Perform a C<GET> request and check for transport errors, takes the exact same
arguments as L<Mojo::UserAgent/"get">.
=head2 C<head_ok>
$t = $t->head_ok('/foo');
$t = $t->head_ok('/foo' => {Accept => '*/*'} => 'Hi!');
$t = $t->head_ok('/foo' => {DNT => 1} => 'Hi!');
Perform a C<HEAD> request and check for transport errors, takes the exact
same arguments as L<Mojo::UserAgent/"head">.
Expand Down Expand Up @@ -637,39 +637,39 @@ Opposite of C<message_like>.
=head2 C<options_ok>
$t = $t->options_ok('/foo');
$t = $t->options_ok('/foo' => {Accept => '*/*'} => 'Hi!');
$t = $t->options_ok('/foo' => {DNT => 1} => 'Hi!');
Perform a C<OPTIONS> request and check for transport errors, takes the exact
same arguments as L<Mojo::UserAgent/"options">.
=head2 C<patch_ok>
$t = $t->patch_ok('/foo');
$t = $t->patch_ok('/foo' => {Accept => '*/*'} => 'Hi!');
$t = $t->patch_ok('/foo' => {DNT => 1} => 'Hi!');
Perform a C<PATCH> request and check for transport errors, takes the exact
same arguments as L<Mojo::UserAgent/"patch">.
=head2 C<post_ok>
$t = $t->post_ok('/foo');
$t = $t->post_ok('/foo' => {Accept => '*/*'} => 'Hi!');
$t = $t->post_ok('/foo' => {DNT => 1} => 'Hi!');
Perform a C<POST> request and check for transport errors, takes the exact
same arguments as L<Mojo::UserAgent/"post">.
=head2 C<post_form_ok>
$t = $t->post_form_ok('/foo' => {a => 'b'});
$t = $t->post_form_ok('/foo' => 'UTF-8' => {a => 'b'} => {Accept => '*/*'});
$t = $t->post_form_ok('/foo' => 'UTF-8' => {a => 'b'} => {DNT => 1});
Submit a C<POST> form and check for transport errors, takes the exact same
arguments as L<Mojo::UserAgent/"post_form">.
=head2 C<put_ok>
$t = $t->put_ok('/foo');
$t = $t->put_ok('/foo' => {Accept => '*/*'} => 'Hi!');
$t = $t->put_ok('/foo' => {DNT => 1} => 'Hi!');
Perform a C<PUT> request and check for transport errors, takes the exact same
arguments as L<Mojo::UserAgent/"put">.
Expand Down Expand Up @@ -735,7 +735,7 @@ Opposite of C<text_like>.
=head2 C<websocket_ok>
$t = $t->websocket_ok('/echo');
$t = $t->websocket_ok('/echo' => 'Accept' => '*/*');
$t = $t->websocket_ok('/echo' => {DNT => 1});
Open a C<WebSocket> connection with transparent handshake, takes the exact
same arguments as L<Mojo::UserAgent/"websocket">.
Expand Down
16 changes: 8 additions & 8 deletions lib/ojo.pm
Expand Up @@ -118,23 +118,23 @@ Turn list into a L<Mojo::Collection> object.
=head2 C<d>
my $res = d('http://mojolicio.us');
my $res = d('http://mojolicio.us' => {Accept => '*/*'} => 'Hi!');
my $res = d('http://mojolicio.us' => {DNT => 1} => 'Hi!');
Perform C<DELETE> request with L<Mojo::UserAgent/"delete"> and return
resulting L<Mojo::Message::Response> object.
=head2 C<f>
my $res = f('kraih.com' => {a => 'b'});
my $res = f('kraih.com' => 'UTF-8' => {a => 'b'} => {Accept => '*/*'});
my $res = f('kraih.com' => 'UTF-8' => {a => 'b'} => {DNT => 1});
Perform C<POST> form request with L<Mojo::UserAgent/"post_form"> and return
resulting L<Mojo::Message::Response> object.
=head2 C<g>
my $res = g('http://mojolicio.us');
my $res = g('http://mojolicio.us' => {Accept => '*/*'} => 'Hi!');
my $res = g('http://mojolicio.us' => {DNT => 1} => 'Hi!');
Perform C<GET> request with L<Mojo::UserAgent/"get"> and return resulting
L<Mojo::Message::Response> object. One redirect will be followed by default,
Expand All @@ -146,39 +146,39 @@ variable.
=head2 C<h>
my $res = h('http://mojolicio.us');
my $res = h('http://mojolicio.us' => {Accept => '*/*'} => 'Hi!');
my $res = h('http://mojolicio.us' => {DNT => 1} => 'Hi!');
Perform C<HEAD> request with L<Mojo::UserAgent/"head"> and return resulting
L<Mojo::Message::Response> object.
=head2 C<o>
my $res = o('http://mojolicio.us');
my $res = o('http://mojolicio.us' => {Accept => '*/*'} => 'Hi!');
my $res = o('http://mojolicio.us' => {DNT => 1} => 'Hi!');
Perform C<OPTIONS> request with L<Mojo::UserAgent/"options"> and return
resulting L<Mojo::Message::Response> object.
=head2 C<p>
my $res = p('http://mojolicio.us');
my $res = p('http://mojolicio.us' => {Accept => '*/*'} => 'Hi!');
my $res = p('http://mojolicio.us' => {DNT => 1} => 'Hi!');
Perform C<POST> request with L<Mojo::UserAgent/"post"> and return resulting
L<Mojo::Message::Response> object.
=head2 C<t>
my $res = t('http://mojolicio.us');
my $res = t('http://mojolicio.us' => {Accept => '*/*'} => 'Hi!');
my $res = t('http://mojolicio.us' => {DNT => 1} => 'Hi!');
Perform C<PATCH> request with L<Mojo::UserAgent/"patch"> and return resulting
L<Mojo::Message::Response> object.
=head2 C<u>
my $res = u('http://mojolicio.us');
my $res = u('http://mojolicio.us' => {Accept => '*/*'} => 'Hi!');
my $res = u('http://mojolicio.us' => {DNT => 1} => 'Hi!');
Perform C<PUT> request with L<Mojo::UserAgent/"put"> and return resulting
L<Mojo::Message::Response> object.
Expand Down

0 comments on commit 7998c53

Please sign in to comment.