我有perl脚本,它使用以下命令设置标题
print "Content-Disposition: attachment; filename=test.csv\n\n";
当在Web服务器IIS和Apache上部署时,此脚本的行为会有所不同。
当代码部署在apache web服务器上时,我可以在android mobile上下载test.csv文件。
但是当在IIS服务器上部署相同的脚本时,Android mobile上的下载总是不成功。
注意:但下载工作就像在任何桌面浏览器中为两个Web服务器使用魅力一样。
以下是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
任何人都可以帮我解决这个问题吗?
谢谢!
答案 0 :(得分:1)
非常感谢您的支持。
我尝试过跟踪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;
谢谢!
答案 1 :(得分:0)
似乎其他人也无法从IIS服务器下载到Android:
http://code.google.com/p/android/issues/detail?id=33362
.apk IIS webserver download error on android 2.3.x
http://www.experts-exchange.com/Programming/Languages/Java/Android/Q_27592118.html
我不认为这是一个Perl问题。但是,我没有看到解决方案。