Skip to content

Commit

Permalink
See only content when status is 2xx, not just 200
Browse files Browse the repository at this point in the history
  • Loading branch information
perlancar committed Oct 28, 2014
1 parent 7f01636 commit 80e51e2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Perinci/Result/Format.pm
Expand Up @@ -12,7 +12,7 @@ our $Enable_Decoration = 1;
our $Enable_Cleansing = 0;

# text formats are special. since they are more oriented towards human instead
# of machine, we remove envelope when status is 200, so users only see content.
# of machine, we remove envelope when status is 2xx, so users only see content.

# XXX color theme?

Expand Down Expand Up @@ -89,7 +89,7 @@ my $format_text = sub {
};

if (!defined($res->[2])) {
my $out = $res->[0] =~ /\A(?:200|304)\z/ ? "" : $print_err->($res);
my $out = $res->[0] =~ /\A(?:2..|304)\z/ ? "" : $print_err->($res);
my $max = 30;
my $i = 0;
my $prev = $res;
Expand All @@ -106,7 +106,7 @@ my $format_text = sub {
return $out;
}
my ($r, $opts);
if ($res->[0] == 200) {
if ($res->[0] =~ /\A2../) {
$r = $res->[2];
my $rfo = $res->[3]{result_format_options} // {};
# old compat, rfo used to be only opts, now it's {fmt=>opts, ...}
Expand Down

0 comments on commit 80e51e2

Please sign in to comment.