Check header before matching its value (#1107)

This commit is contained in:
Clément Oudot 2016-11-14 10:27:18 +00:00
parent 30aa96fc82
commit d46c33fbf4
2 changed files with 6 additions and 2 deletions

View File

@ -137,7 +137,10 @@ has error => ( is => 'rw', isa => 'Str', default => '' );
has respHeaders => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } );
sub wantJSON {
return $_[0]->accept =~ m#(?:application|text)/json# ? 1 : 0;
return 1
if ( defined $_[0]->accept
and $_[0]->accept =~ m#(?:application|text)/json# );
return 0;
}
# JSON parser

View File

@ -1528,7 +1528,8 @@ sub process {
issuerForAuthUser autoRedirect)
);
$self->updateStatus;
if ( !$self->{noAjaxHook}
if ( !$self->{noAjaxHook}
and defined $self->http('Accept')
and $self->http('Accept') =~ m#(?:application|text)/json# )
{
if ( ( my $code = $self->{error} ) > 0 ) {