IE tries to download json/application

      最近用blueimp上传图片的时候,发现在ie下上传失败,总是提示下载文件。后研究发现,是由于ie8不支持aplication/json的缘故,故需要强制将ie的content-type设定为text/plain ,设置代码如下:

                                      if (isset($_SERVER['HTTP_ACCEPT']) &&

(strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false)) {

$response->headers->set('Content-type', 'application/json; charset=utf-8');

} else {

$response->headers->set('Content-type', 'text/plain; charset=utf-8');

}。

    因为本人项目中用的是symfony2,对于项目返回的response的对象在eventLister中的onKernelResponse方法中做了统一处理,所以在control中修改header的content-type信息一直失败。后来才发现eventLister中有关于 这个统一设定。

 

     参考资料:  

        ie  不支持  aplication/json :

          https://github.com/blueimp/jQuery-File-Upload/issues/123

          https://github.com/astaxie/beego/issues/165

          http://stackoverflow.com/questions/13943439/json-response-download-in-ie710

         https://github.com/blueimp/jQuery-File-Upload/issues/123     

         http://stackoverflow.com/questions/13943439/json-response-download-in-ie710

 

       accept:Vary:

         http://stackoverflow.com/questions/1975416/trying-to-understand-the-vary-http-header

          http://keystonewebsites.com/articles/mime_type.php

       http://www.456bereastreet.com/archive/200408/content_negotiation/

       http://blogs.msdn.com/b/ieinternals/archive/2009/06/17/vary-header-prevents-caching-in-ie.aspx

      http://blogs.msdn.com/b/ieinternals/archive/2009/06/17/vary-header-prevents-caching-in-ie.aspx

 

 

 

 

  

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值