Symfony2的。我无法设置Content-Length标题 [英] Symfony2. I can't set Content-Length header

查看:137
本文介绍了Symfony2的。我无法设置Content-Length标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这是我的控制器动作:

$ b我是Simfony的新手,我试图在响应中设置一个Content-Length标题。
$ b

  public function homepageAction(){

$ content = $ this> renderView('AcmeBlogBu​​ndle:Pages / homepage:homepage_content.html 。枝条');

$ response = new Response();

$ response-> setContent($ content);

$ response-> headers-> set('Content-Length:1736233495'); //手动添加的值

返回$ response;

} //主页

我得到一个错误500内部服务器错误。

解决方案

您是否尝试 $ response-> headers-> set('Content-Length ',1736233495);



编辑:文档


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.

解决方案

Did you try to $response->headers->set('Content-Length', 1736233495); ?

EDIT : Documentation

这篇关于Symfony2的。我无法设置Content-Length标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆