因此,android 浏览器或 webview 可以很好地处理这样的网址 - abc.com/xyz.txt
但是,如果您的 URL 看起来像这样 - abc.com/xyz.php 并且在标头中发送到浏览器的是 - Content-Disposition: attachment; filename="xyz.txt",那么 Android 浏览器和 web 视图似乎变得非常混乱。
看起来它在手机上保存了正确的文件名,但内容充满了之前正在查看的网页。这在基于 PC 的浏览器以及 iPhone 和 Blackberry 上运行良好,这只是 Android 2.1 和 2.2 上的问题(尚未测试其他版本)。
有人有解决方案吗?将不胜感激。我真的不想开始存储静态文件并想即时生成我的下载内容。手机上的日志没有显示任何线索。
这是服务器发送到浏览器的内容
===================== start content ====================================
HTTP/1.1 200 OK
Date: Thu, 21 Oct 2010 21:22:11 GMT
Server: Apache
Content-Disposition: attachment; filename="Wafty.txt"
Content-length: 30
Content-Type: text/plain; charset=ISO-8859-1
Hello this is a test of a file
========= There was no carriage return at the end of the above line ====