开发者

Error opening PDF in browser - what HTTP header values should I use for streaming a PDF over https?

开发者 https://www.devze.com 2022-12-11 10:28 出处:网络
I have a J2EE webapp which is used to download a generated PDF served by an HTTP servlet. When running over SSL in production the users are getting the error message

I have a J2EE webapp which is used to download a generated PDF served by an HTTP servlet. When running over SSL in production the users are getting the error message

There was an error opening this document. The file cannot be found.

in Acrobat when they choose to open the file in the browser instead of saving it to file. If they save the file there is no problem. The error only occurs in production which is an Oracle Application Server cluster behind an F5 BIG-IP router. In test the problem does not occur even over https.

The current headers being sent are

Content-disposition: attachment; filename=myfile.pdf
Pragma: public
Cache-control: must-revalid开发者_StackOverflow社区ate

Has anyone experienced this problem in the past? What values should I be using for these headers? Should I be using inline content-disposition instead of attachment?


I fixed it by adding these 2 headers:

Pragma: public Cache-control: maxage=1

http://us.php.net/manual/en/function.header.php#83219


It may help to ensure that the URL being called ends in ".pdf", or even "filename.pdf", as IE (aparently) uses the URL to determine filetype.

0

精彩评论

暂无评论...
验证码 换一张
取 消