Skip to content

Commit

Permalink
better JSON POST examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 19, 2012
1 parent 5f34637 commit 8cac005
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,7 +1,7 @@

3.12 2012-07-20
- Added json method to Mojo::UserAgent::Transactor.
- Added built_json_tx and post_json methods to Mojo::UserAgent.
- Added build_json_tx and post_json methods to Mojo::UserAgent.
- Added post_json_ok method to Test::Mojo.
- Added json_class attribute to Mojo::UserAgent::Transactor.
- Added n function to ojo.
Expand Down
9 changes: 5 additions & 4 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -561,8 +561,9 @@ Mojo::UserAgent - Non-blocking I/O HTTP 1.1 and WebSocket user agent
$ua->max_redirects(5)->get('latest.mojolicio.us')
->res->content->asset->move_to('/Users/sri/mojo.tar.gz');
# TLS certificate authentication
my $tx = $ua->cert('tls.crt')->key('tls.key')->get('https://mojolicio.us');
# TLS certificate authentication and JSON POST
my $tx = $ua->cert('tls.crt')->key('tls.key')
->post_json('https://mojolicio.us' => {top => 'secret'});
# Blocking parallel requests (does not work inside a running event loop)
my $delay = Mojo::IOLoop->delay;
Expand Down Expand Up @@ -834,7 +835,7 @@ Alias for L<Mojo::UserAgent::Transactor/"form">.
=head2 C<build_json_tx>
my $tx = $ua->build_json_tx('http://kraih.com' => {a => 'b'});
my $tx = $ua->build_json_tx('kraih.com', {a => 'b'}, {DNT => 1});
my $tx = $ua->build_json_tx('kraih.com' => {a => 'b'} => {DNT => 1});
Alias for L<Mojo::UserAgent::Transactor/"json">.
Expand Down Expand Up @@ -986,7 +987,7 @@ perform requests non-blocking.
=head2 C<post_json>
my $tx = $ua->post_json('http://kraih.com' => {a => 'b'});
my $tx = $ua->post_json('kraih.com', {a => 'b'}, {DNT => 1});
my $tx = $ua->post_json('kraih.com' => {a => 'b'} => {DNT => 1});
Perform blocking HTTP C<POST> request with JSON data and return resulting
L<Mojo::Transaction::HTTP> object, takes the exact same arguments as
Expand Down

0 comments on commit 8cac005

Please sign in to comment.