Copy over the ETag and LastModified when formatting a Dataresponse

This way the ETag checks etc are all working.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2020-05-19 09:39:51 +02:00 committed by backportbot[bot]
parent 822d3f0e8b
commit b9cb5a74cc
1 changed files with 8 additions and 0 deletions

View File

@ -91,6 +91,14 @@ abstract class Controller {
unset($headers['Content-Type']); unset($headers['Content-Type']);
} }
$response->setHeaders(array_merge($dataHeaders, $headers)); $response->setHeaders(array_merge($dataHeaders, $headers));
if ($data->getETag() !== null) {
$response->setETag($data->getETag());
}
if ($data->getLastModified() !== null) {
$response->setLastModified($data->getLastModified());
}
return $response; return $response;
} }
return new JSONResponse($data); return new JSONResponse($data);