小编teo*_*atl的帖子

symfony:setHttpHeader()不起作用,header()没有

我在symfony中构建了一个简单的动作,它通过wkhtmltopdf生成一个PDF文件并将其输出到浏览器.

这是代码:

  $response = $this->getResponse();
  $response->setContentType('application/pdf');
  $response->setHttpHeader('Content-Disposition', "attachment; filename=filename.pdf");
  $response->setHttpHeader('Content-Length', filesize($file));
  $response->sendHttpHeaders();
  $response->setContent(file_get_contents($file));
  return sfView::NONE;
Run Code Online (Sandbox Code Playgroud)

这在我的本地开发环境中工作正常 - 我的浏览器按预期获得标题,显示下载对话.

现在我更新了我的测试环境,用PHP 5.3.5-0.dotdeb.0运行Apache 2.2.9-10 + lenny9.如果我现在为测试环境调用该URL,我的浏览器不会获得任何自定义设置标头:

Date    Mon, 07 Mar 2011 10:34:37 GMT
Server  Apache
Keep-Alive  timeout=15, max=100
Connection  Keep-Alive
Transfer-Encoding   chunked
Run Code Online (Sandbox Code Playgroud)

如果我在动作中通过header()手动设置它们,Firebug会按预期显示标题.有人知道什么可能是错的吗?它是symfony bug,还是php或apache2配置问题?我不明白.: - /

提前致谢!

php symfony1 apache2 http-headers symfony-1.4

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

apache2 ×1

http-headers ×1

php ×1

symfony-1.4 ×1

symfony1 ×1