关于:HTTP Header -> Content-Type: text/plain Cache-Control: no-cache IE浏览器弹出错误下载对话

下午遇到一个很奇怪的现象,一个网址: http://192.168.1.3/login?action=a&fr=b.com

注意网址后面的参数形式,action参数在前,最后一个参数值的尾部含有.com

login程序的代码是这样的:

pw.println("Content-Type: text/plain");

pw.println("Cache-Control: no-cache");

pw.println("Content-Length: " + "abcd".getBytes().length); //内容大小

pw.println();

pw.print("abcd"); 
pw.flush();

如果有IE浏览器的地址栏里直接输入网址,按回车后,并不会显示abcd,而是会弹出一个下载对话框:

经过3个小时的测试,发现:

1. 当Content-Type设置为 text/plain ,同时设置 Cache-Control: no-cache,在IE浏览器上就会出现下载对话框,但在firefox和chrome上可以正常显示abcd

2. 当Content-Type设置为 text/plain ,同时设置 Cache-Control: private 或 不设置 Cache-Control,在IE浏览器上可以正常显示abcd

3. 当Content-Type设置为 text/html,同时设置 Cache-Control: no-cache,在IE浏览器上可以正常显示abcd

4. 在IE浏览器中,前面一个参数是action最后一个参数值是.com,就会出现上面这样的问题,在其它浏览器可以正常显示内容。

5. 在IE浏览器中,如果把action参数放到最后,把fr参数放到前面,就可以显示出 abcd

种种迹象表明:

在ie浏览器中,如果直接把上面的 http://192.168.1.3/login?action=a&fr=b.com复制到地址栏中按回车直接打开的时候:

1. 如果程序中返回的Content-Type: text/plain 那么HTTP状态码一定要HTTP/1.1 200 OK才行,不然就会出现一个错误的下载对话框,其它浏览器不存在这样的问题
2. 反之,如果 Content-Type: text/html,那么HTTP状态码可以是其它的各种类型状态码。

另注:如果用户是从一个链接上点击进入这个网址,则可以正常显示内容,而不会出现像上面那样的错误对话框。

2011-07-06

时间: 2024-12-20 23:20:50

关于:HTTP Header -> Content-Type: text/plain Cache-Control: no-cache IE浏览器弹出错误下载对话的相关文章

postman测试接口报Content type 'text/plain;charset=UTF-8' not supported解决方法

增加一个请求头管理器,添加content-type:application/json.并将请求修改为json数据传输试试. 参考:https://zhidao.baidu.com/question/1644957725975214740.html postman测试接口报Content type 'text/plain;charset=UTF-8' not supported解决方法 原文地址:https://www.cnblogs.com/xiaoni-fighting/p/12298436.

Chrome 报 Resource interpreted as Script but transferred with MIME type text/plain 警告的解决办法

http://www.2cto.com/os/201312/262437.html 安装了VS2012之后,chrome在加载页面的时候会报 Resource interpreted as Script but transferred with MIME type text/plain 的警告. 这是因为VS2012在安装的时候改了windows的注册表,将解析javascript的类型标示改成了text/plain,导致javascript被转换成了text/plain格式,但这并不影响jav

发邮件抛异常。no object DCH for MIME type text/plain; charset=UTF-8

在进行发邮件的时候抛出的这个异常: IOException while sending message; nested exception is: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/plain; charset=UTF-8 检查在站点的lib文件夹下和在tomcat的common的lib下边是不是同时存在mail.jar and activation.jar,没有的话加进

springBoot+thymeleaf遇到Resource interpreted as Stylesheet but transferred with MIME type text/plain

如果你在项目中使用了拦截器,那么你的拦截器配置就应该排除拦截css静态资源,如下图所示: 这样浏览器控制台上就不会出现Resource interpreted as Stylesheet but transferred with MIME type text/plain提示了,页面也能恢复正常了. 原文地址:https://www.cnblogs.com/JerryTomcat/p/11721258.html

nginx - Resource interpreted as Stylesheet but transferred with MIME type text/plain

在部署前端项目的时候,网站跑起来了,可就是css样式没加载出来,查看css文件也已经load进来,被坑了3个小时终于发现问题所在: nginx.conf中添加下面两行配置即可,可参考nginx默认配置文件 include mime.types; default_type application/octet-stream; 如果不设置css文件就会被当作text/plain类型发送到浏览器.从而导致css样式无法显示

RestTemplate 微信接口 text/plain HttpMessageConverter

一.背景介绍 使用 Spring Boot 写项目,需要用到微信接口获取用户信息. 在 Jessey 和 Spring RestTemplate 两个 Rest 客户端中,想到尽量不引入更多的东西,然后就选择了 Spring RestTemplate 作为 网络请求的 Client,然后就被微信接口摆了一道,然后踩了一个 RestTemplate 的坑. 二.第一个坑:被微信摆了一道 报错信息是: org.springframework.web.client.RestClientExceptio

No handler for type [text] declared on field [content]

Install 1.compile checkout ik version respective to your elasticsearch version git checkout tags/{version} mvn package copy and unzip target/releases/elasticsearch-analysis-ik-{version}.zip to your-es-root/plugins/ik 2.restart elasticsearch Tips: ik_

谷歌,火狐提示来自"http://xxx.com/file"的资源已被阻止,因为 MIME 类型("text/plain")不匹配(X-Content-Type-Options: nosniff),如何解决?

在使用ueditor编辑的过程中无法上传图片,谷歌火狐浏览器提示Cross-Origin Read Blocking (CORB) blocked cross-origin response http://XXX?action=config&callback=bd__editor__dkhbuv with MIME type text/plain,怎么解决?查看该文件请求,发现服务器返回头中多了这么个玩意 X-Content-Type-Options: nosniff,这个是什么意思呢? 查阅资

the request doesn't contain a multipart/form-data or multipart/form-data stream, content type header

the request doesn't contain a multipart/form-data or multipart/form-data stream, content type header 一,HTTP上传的基本知识 在Form元素的语法中,EncType表明提交数据的格式 用 Enctype 属性指定将数据回发到服务器时浏览器使用的编码类型.下边是说明: application/x-www-form-urlencoded: 窗体数据被编码为名称/值对.这是标准的编码格式. mult