【发布时间】:2014-02-25 13:19:50
【问题描述】:
我在一个用于 PDF 文件下载的应用程序中有一些遗留代码(PDF 文件大小约为 350-400KB),最近我们(大约 1% 的客户)抱怨说 PDF 下载失败并损坏/损坏文件错误。
这里是用于下载的代码(C++ 应用程序)设置标头的 sn-p
String header;
header.append("Content-type: application/force-download\r\n");
header.append("Content-Transfer-Encoding: Binary\r\n");
header.append("Content-length: %d\r\n", filebuf.length());
header.append("Connection: Close\r\n");
header.append("Content-disposition: attachment; filename=%s\r\n\r\n", filename_to_download.chars());
String类和append方法只是一个例子。
我了解上述标题不是触发 PDF 文件下载的最佳方式(我通过“Content-Type application/octet-stream and Content-Disposition : attachment; filename=example.pdf”简化了标题,看起来像它对我有用)。
但我无法理解为什么上面的原始代码不能在 1% 的时间内工作。
我试图了解浏览器/adobe 的组合,但这里似乎没有模式,是的,很少有客户提到的一件事是,当他们改用“chrome 浏览器”时,它在大多数情况下都能正常工作。
任何指针?
【问题讨论】:
标签: c++ pdf http-headers download