forked from lix-project/hydra
Set Vary to Accept
Otherwise, the browser may mix up HTML and JSON responses if it has requested both. For example, hitting the back button to return to a job metric page will show a JSON response, because that was the last thing the browser fetched for that URL. This requires Catalyst::Action::Rest >= 1.20.
This commit is contained in:
parent
32adc53070
commit
ed88bbaac0
|
@ -67,6 +67,10 @@ sub begin :Private {
|
|||
unless (defined $c->stash->{params} and %{$c->stash->{params}}) {
|
||||
$c->stash->{params} = $c->request->params;
|
||||
}
|
||||
|
||||
# Set the Vary header to "Accept" to ensure that browsers don't
|
||||
# mix up HTML and JSON responses.
|
||||
$c->response->headers->header('Vary', 'Accept');
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue