TT#40540 fix Accept Header treatment

the accept header can contain a list of comma-separated values. If only
one of those is application/json or */*, we should send that.

Example of an Accept header:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Change-Id: I45bdea5dca05060c1cc17ce5bbdff9c58cb5ca72
changes/80/22280/3
Gerhard Jungwirth 8 years ago
parent 9b071717ba
commit b712de8438

@ -189,14 +189,14 @@ sub get {
my $action_config = $self->get_config('action');
if( ( defined $header_accept
&& ($header_accept ne 'application/json')
&& ($header_accept ne '*/*')
&& ($header_accept !~ m!\bapplication/json\b|\b\*/\*\b!) # application/json OR */*
)
|| ( $action_config->{GET}->{ReturnContentType}
&& $action_config->{GET}->{ReturnContentType} ne 'application/json'
)
) {
$self->return_requested_type($c,$id,$item);
# in case this method is not defined, we should return a reasonable error explaining the Accept Header
return;
}

Loading…
Cancel
Save