gpt4 book ai didi

perl - 文件下载结果在 "IE was not able to open this internet site"

转载 作者:行者123 更新时间:2023-12-04 01:03:04 24 4
gpt4 key购买 nike

我对这个不知所措。我已经四处看了看,似乎有很多解决方案,但它们对我不起作用。我有一个 CGI::Application 应用程序,它使用 Spreadsheet::WriteExcel 生成 MS Excel 电子表格。这在很长一段时间内运行良好,直到几周前我们的实时服务器出现硬件故障。我们以中断为借口升级到 Windows Server 2008(从 2003 年开始)和 Apache 2.2.17(从 2.2.11 开始)。现在,我收到客户在尝试下载电子表格时收到此错误的零星(但太频繁而无法忽略)投诉:

Internet Explorer cannot download [url] from [site].
Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.



我曾在 XP、Vista 和 7 上尝试过 IE 7-8,但无法在本地重现此错误。有问题的用户每次都会遇到,而不是随机出现。所有的投诉都来自 IE 用户,主要是在 IE8 上。

在阅读了几篇关于错误消息的帖子后,我添加了 -expires标题无济于事。 (无法直接测试,我不得不实现修复并等待一天左右,看看人们是否停止提示 ._. )
sub export_spreadsheet {
my $self = shift;
binmode STDOUT;

my $str;
open my $fh, '>', \$str;
my $workbook = Spreadsheet::WriteExcel->new($fh);
# words words words
$workbook->close;
close $fh;

$self->header_add(-type => 'application/vnd.ms-excel',
-expires => '+1d',
-attachment => 'export.xls');
return $str;
}

请求的 header 看起来很正常。请注意,这些是在我的本地机器上收集的。
HTTP/1.1 200 OK
Date: Tue, 31 May 2011 22:23:17 GMT
Server: Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o mod_perl/2.0.4-dev Perl/v5.10.1
Expires: Wed, 01 Jun 2011 22:23:18 GMT
Content-Disposition: attachment; filename="export.xls"
Vary: Accept-Encoding
Keep-Alive: timeout=5, max=100
Content-Type: application/vnd.ms-excel
Content-Length: 18944
Accept-Ranges: none
Proxy-Connection: Keep-Alive

我们为客户提供的当前解决方法(无法或不愿意切换到备用浏览器)是通过输入 https 来切换到 SSL。他们自己。 SSL 下载对于那些尝试过并回复我们的人来说效果很好。推测:会不会是下游代理弄乱了我们的 header ?这可能是它在 SSL 中工作而在纯 HTTP 中出错的原因吗? (在这种情况下,服务器升级将是一个不幸的巧合。)

最佳答案

根据 http://support.microsoft.com/kb/316431 IE 无法处理文件未缓存但随后被某些外部进程打开的情况。这不是完全相同的情况,但正如 EricLaw 在评论中提到的那样,它可能与 Vary 有关。标题以及下载没有文件名的事实。

我会删除该标题并为其指定一个文件名,IE 应该能够将文件保存到磁盘,以便 Excel 可以打开它。

关于perl - 文件下载结果在 "IE was not able to open this internet site",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6194755/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com