我有 perl 脚本,它使用以下命令设置 header
print "Content-Disposition: attachment; filename=test.csv\n\n";
当部署在 Web 服务器 IIS 和 Apache 上时,此脚本的行为有所不同。
当代码部署在 apache 网络服务器上时,我可以在 android 移动设备上下载文件 test.csv。
但是同样的脚本部署到IIS服务器上,android手机上总是下载不成功。
注意:但是对于两个 Web 服务器,下载在任何桌面浏览器中都像 charm 一样有效。
以下是来自IIS的响应头
(Status-Line) HTTP/1.1 200 OK
Server Microsoft-IIS/6.0
Content-Disposition attachment; filename=test.csv
X-Powered-By ASP.NET
Date Thu, 31 Jan 2013 10:10:59 GMT
Connection close
以下是来自Apache的响应头
(Status-Line) HTTP/1.1 200 OK
Date Thu, 31 Jan 2013 10:12:33 GMT
Server Apache/2.2.22 (Win32)
Content-Disposition attachment; filename=test.csv
Keep-Alive timeout=5, max=100
Connection Keep-Alive
Transfer-Encoding chunked
Content-Type text/plain
谁能帮我解决这个问题?
谢谢!
最佳答案
非常感谢您的支持。
我尝试遵循 perl 代码,它帮助我解决了问题
# Set the header using following way
print "Content-Type: text/plain", "\n";
print "Content-length: $length", "\n";
print "Content-Disposition: attachment; filename=test.csv\n\n";
注意:$length 是一个变量,它存储文件内容的长度,如下所示
my $csv = "testing";
my $length = length $csv;
谢谢!
关于android - Perl 代码输出在 IIS 和 Apache 中的行为不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14627708/