Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
improved get command to not depend on Content-Type headers for differ…
…entiating between JSON and HTML/XML
  • Loading branch information
kraih committed Sep 21, 2014
1 parent f25efce commit 49f505b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Changes
@@ -1,7 +1,9 @@

5.43 2014-09-21
5.43 2014-09-22
- Updated Makefile.PL for version 2 of the CPAN distribution metadata
specification.
- Improved get command to not depend on Content-Type headers for
differentiating between JSON and HTML/XML.

5.42 2014-09-17
- Fixed url_for bug where an unnecessary slash could be rendered before
Expand Down
6 changes: 2 additions & 4 deletions lib/Mojolicious/Command/get.pm
Expand Up @@ -66,14 +66,12 @@ sub run {
STDOUT->autoflush(1);
my $tx = $ua->start($ua->build_tx($method, $url, \%headers, $content));
my $err = $tx->error;
$url = encode 'UTF-8', $url;
warn qq{Problem loading URL "$url". ($err->{message})\n}
warn qq{Problem loading URL "@{[$tx->req->url]}". ($err->{message})\n}
if $err && !$err->{code};

# JSON Pointer
return unless defined $selector;
my $type = $tx->res->headers->content_type // '';
return _json($buffer, $selector) if $type =~ /json/i;
return _json($buffer, $selector) if $selector eq '' || $selector =~ m!^/!;

# Selector
_select($buffer, $selector, $charset // $tx->res->content->charset, @args);
Expand Down
3 changes: 1 addition & 2 deletions lib/ojo.pm
Expand Up @@ -45,8 +45,7 @@ sub _request {

my $tx = $ua->start($ua->build_tx(@_));
my $err = $tx->error;
warn
qq/Problem loading URL "@{[$tx->req->url->to_abs]}". ($err->{message})\n/
warn qq/Problem loading URL "@{[$tx->req->url]}". ($err->{message})\n/
if $err && !$err->{code};

return $tx->res;
Expand Down

0 comments on commit 49f505b

Please sign in to comment.