资源解释为Document,但是使用MIME类型application / zip进行传输 [英] Resource interpreted as Document but transferred with MIME type application/zip

查看:939
本文介绍了资源解释为Document,但是使用MIME类型application / zip进行传输的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Chrome 12.0.742.112,如果我使用以下标头进行重定向:

  HTTP / 1.1 302找到
位置: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
服务器:WEBrick / 1.3.1(Ruby / 1.9.2 / 2011-02-18)
日期:2011年7月5日星期二18:42:25 GMT
连接:Keep-Alive

如果遵循则返回以下标题:

  HTTP / 1.1 200 OK 
上次修改时间:2011年7月5日星期二18:18:30 GMT
Content-Type:application / zip
Content-Length :150014
服务器:WEBrick / 1.3.1(Ruby / 1.9.2 / 2011-02-18)
日期:2011年7月5日星期二18:44:47 GMT
连接:Keep -Alive

Chrome不会重定向,也不会更改上一页,它只会报告以下警告在控制台中:


资源解释为Document,但是使用MIME类型application / zip传输。




这个过程在Firefox中正常工作,如果我打开一个新标签并转到直接到 http://0.0.0.0:3000/files/download.zip 。我是否做错了什么,或者这是Chrome的一个bug /怪癖?

解决方案

一个新的标签。



为什么它不起作用我不完全确定,但它可能与Chrome处理页面上的多次下载有关,也许它认为它们是垃圾邮件,只是忽略它们而已。


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 will not redirect, nor change the previous page, it'll just report the following warning in the console:

Resource interpreted as Document but transferred with MIME type application/zip.

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.

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.

这篇关于资源解释为Document,但是使用MIME类型application / zip进行传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆