Skip to content

Commit

Permalink
improved get command to use the user agent of the application
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 14, 2015
1 parent 0283ada commit fe192a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -7,6 +7,7 @@
- Removed deprecated support for data arguments from Mojo::JSON::Pointer.
- Removed deprecated AUTOLOAD and pluck methods from Mojo::Collection.
- Removed deprecated AUTOLOAD and val methods from Mojo::DOM.
- Improved get command to use the user agent of the application.
- Fixed JSON Pointer escaping bug.
- Fixed portability bug in monkey_patch tests.

Expand Down
6 changes: 3 additions & 3 deletions lib/Mojolicious/Command/get.pm
Expand Up @@ -6,7 +6,6 @@ use Mojo::DOM;
use Mojo::IOLoop;
use Mojo::JSON qw(encode_json j);
use Mojo::JSON::Pointer;
use Mojo::UserAgent;
use Mojo::Util qw(decode encode);
use Scalar::Util 'weaken';

Expand All @@ -32,8 +31,9 @@ sub run {
my %headers = map { /^\s*([^:]+)\s*:\s*(.+)$/ ? ($1, $2) : () } @headers;

# Detect proxy for absolute URLs
my $ua = Mojo::UserAgent->new(ioloop => Mojo::IOLoop->singleton);
$url !~ m!^/! ? $ua->proxy->detect : $ua->server->app($self->app);
my $ua = $self->app->ua->ioloop(Mojo::IOLoop->singleton);
$ua->server->ioloop(Mojo::IOLoop->singleton);
$ua->proxy->detect unless $url !~ m!^/!;
$ua->max_redirects(10) if $redirect;

my $buffer = '';
Expand Down

0 comments on commit fe192a0

Please sign in to comment.