问题
i am new on Simfony and I am trying to set a Content-Length header in my response.
This is my controller action:
public function homepageAction() {
$content= $this>renderView('AcmeBlogBundle:Pages/homepage:homepage_content.html.twig');
$response= new Response();
$response->setContent($content);
$response->headers->set('Content-Length: 1736233495'); // value added manually
return $response;
} // homepage
i obtain an error 500 internal server error.
回答1:
Did you try to $response->headers->set('Content-Length', 1736233495);
?
EDIT : Documentation
回答2:
Maybe the "-" missing in the "$this>renderView" part ?
来源:https://stackoverflow.com/questions/24956349/symfony2-i-cant-set-content-length-header