HTTP Header problem
I am using symfony 1.4. I have created one pdf and displaying in a new window. After I displayed the pdf when I click on other links I got the below kind of code. I think it showing my html source file.
How to resolve this problem?
141070HTTP/1.1 200 OK Date: Wed, 13 Apr 2011 13:22:07 GMT Server: Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhe开发者_运维百科l5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 X-Powered-By: PHP/5.3.4 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Keep-Alive: timeout=15, max=94 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html; charset=utf-8 ... ... ...
This is my symfony code to display pdf.
$this->getResponse()->clearHttpHeaders();
$this->getResponse()->setHttpHeader('Content-Disposition', 'inline; filename="' . basename($path) . '"');
$this->getResponse()->setHttpHeader('Content-type', 'application/pdf');
$this->getResponse()->setHttpHeader('Pragma: public', true);
$this->getResponse()->setHttpHeader('Expires', 0);
$this->getResponse()->setHttpHeader('Content-Transfer-Encoding', 'binary');
$this->getResponse()->setHttpHeader('Content-Length', filesize($path));
$this->getResponse()->sendHttpHeaders();
ob_clean();
flush();
echo readfile($path);
Where does 141070
come from? It's the first that is sent to the client, and it should be HTTP/1.1 200 OK
that triggers HTML rendering.
The client probably don't know what to do with the data and therefor render it directly.
精彩评论