android - Perl 代码输出在 IIS 和 Apache 中的行为不同

标签 android perl apache iis http-headers

我有 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/

相关文章:

php - mod_rewrite {QUERY_STRING}

android - 如果 textview 中的文本很大 Android,Textview 会超越 ImageView 吗?

java - SQLite数据库什么时候创建的?

android - 点 42 - 导航到资源文件夹中的 HTML

带有背景提示的 Android Searchview

spring - FAIL - 上下文路径/icescrum 中的应用程序无法启动

php - 我如何捕获 KILL 或 HUP 或用户中止信号?

perl - 为什么我的 perl Catalyst redirect_and_detach 替换插件方法失败?

perl - 如何在 Perl foreach 循环中一次读取两个项目?

java - Angular JS , Tomcat Apache , # Urls