Symfony2. I can't set Content-Length header

走远了吗. 提交于 2019-12-11 12:10:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!