资源被解释为文档但使用 MIME 类型应用程序/zip 传输 [英] Resource interpreted as Document but transferred with MIME type application/zip
问题描述
使用 Chrome 12.0.742.112,如果我使用以下标头重定向:
With Chrome 12.0.742.112, if I redirect with the following headers:
HTTP/1.1 302 Found
Location: http://0.0.0.0:3000/files/download.zip
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
X-Ua-Compatible: IE=Edge
X-Runtime: 0.157964
Content-Length: 0
Server: WEBrick/1.3.1 (Ruby/1.9.2/2011-02-18)
Date: Tue, 05 Jul 2011 18:42:25 GMT
Connection: Keep-Alive
如果遵循,则返回以下标题:
Which if followed returns the following header:
HTTP/1.1 200 OK
Last-Modified: Tue, 05 Jul 2011 18:18:30 GMT
Content-Type: application/zip
Content-Length: 150014
Server: WEBrick/1.3.1 (Ruby/1.9.2/2011-02-18)
Date: Tue, 05 Jul 2011 18:44:47 GMT
Connection: Keep-Alive
Chrome 不会重定向,也不会更改上一页,它只会在控制台中报告以下警告:
Chrome will not redirect, nor change the previous page, it'll just report the following warning in the console:
资源被解释为 Document 但使用 MIME 类型 application/zip 传输.
Resource interpreted as Document but transferred with MIME type application/zip.
该过程在 Firefox 中正常运行,如果我打开一个新选项卡并直接转到 http://0.0.0.0:3000/files/download.zip
,该过程在 Chrome 中也能正常运行.我做错了什么,还是这是 Chrome 的错误/怪癖?
The process works correctly in Firefox, and also works fine in Chrome if I open a new tab and go directly to http://0.0.0.0:3000/files/download.zip
. Am I doing something wrong, or is this a bug/quirk of Chrome?
推荐答案
我已经解决了这个问题……只需打开一个新标签即可.
I've fixed this…by simply opening a new tab.
为什么它不起作用我不完全确定,但这可能与 Chrome 如何处理页面上的多次下载有关,也许它认为它们是垃圾邮件而只是忽略了它们.
Why it wasn't working I'm not entirely sure, but it could have something to do with how Chrome deals with multiple downloads on a page, perhaps it thought they were spam and just ignored them.
这篇关于资源被解释为文档但使用 MIME 类型应用程序/zip 传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!