为什么Chrome for iOS插入图片/ webp内容类型? [英] Why does Chrome for iOS insert image/webp content-type?

查看:244
本文介绍了为什么Chrome for iOS插入图片/ webp内容类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过$ .get()发出AJAX请求的移动web应用程序。该请求对Safari iOS成功,但针对状态为0且statusText为错误的Chrome浏览器无法使用。



在我的服务器上使用tcpdump,我可以看到Safari发送/收到以下标题:

 接受:* / *(离开)

内容类型:文本/ plain; charset = ISO-8859-1(返回)

Chrome for iOS会添加MIME类型image / webp到传出的Accept:标头,Content-Type返回的是image / webp:

  Accept: * / *,image / webp(传出)

HTTP / 1.1 200 OK
Content-Type:image / webp(返回)
pre>

通过阅读jQuery代码,它看起来像$ .get()仅分析AJAX响应中的某些内容类型,所以我认为图像MIME类型是只是被拒绝,导致出现错误状态。



在iOS版Chrome的请求到达我的服务器时,还有这个标头:



Via:1 .1 Chrome-Compression-Proxy



...这表示Chrome for iOS已将请求发送给Google代理服务器以处理请求(info https://support.google.com/chrome/answer/3517349?hl= EN )。似乎这个代理服务器正在设置额外的内容类型,不知怎的,内容类型在返回的时候会返回为image / webp?服务器代码是RESTful Spring 3;我在控制器代码中将内容类型设置为text / plain,但不知何故,这并没有被采用,它仍然以image / webp的形式返回。

任何人都有类似的问题,并找到了解决办法?我需要返回Content-Type的text / plain才能将数据正确地返回给我的应用程序。这个请求也适用于Android的Chrome以及AFAIK,并没有为此做过tcpdump,但该应用正常工作;仅在iOS版Chrome上失败。

解决方案

我们遇到同样的问题:Chrome for iOS更喜欢webp,作为接受:image / webp,* / *; q = 0.8 。实现这种变化的人显然从未想过这种影响,所以这会导致相当多的API返回415

有关更多信息,请参阅: https://code.google.com/p/chromium/issues/detail?id=169182 < a>



最后我们修改了服务器本身,因为它会返回一个415.在响应方面,它应该都很顺利。


I have a mobile web app that is making an AJAX request via $.get(). The request succeeds for Safari iOS, but fails for Chrome for iOS with status 0 and statusText "error".

Using tcpdump on my server, I can see that Safari sends/receives the following headers:

Accept: */*    (outgoing)

Content-Type: text/plain;charset=ISO-8859-1    (returning)

Chrome for iOS adds a mime type of "image/webp" to the outgoing Accept: header and the Content-Type returned is "image/webp":

Accept: */*,image/webp  (outgoing)

HTTP/1.1 200 OK
Content-Type: image/webp   (returning)

Reading through the jQuery code, it looks like $.get() only parses certain content types in AJAX responses, so I'm thinking that an image mime type is just being rejected, resulting in the "error" status.

In the request from Chrome for iOS as it arrives on my server, there's also this header:

Via: 1.1 Chrome-Compression-Proxy

...which indicates that Chrome for iOS has sent the request to a Google proxy server to service the request (info https://support.google.com/chrome/answer/3517349?hl=en). Seems like this proxy server is setting the extra content type, and somehow the content type is returned as image/webp on the way back? The server code is RESTful Spring 3; I do set the content type as "text/plain" in the controller code, but somehow that's not being taken and it's still returning as "image/webp".

Has anyone had a similar problem and found a solution for it? I need to have a return Content-Type of "text/plain" to get the data back correctly to my app. This request works correctly on Chrome for Android as well AFAIK, haven't done a tcpdump for that, but the app works correctly; only fails on Chrome for iOS.

解决方案

We are encountering the same issue: Chrome for iOS prefers webp, so it sends its headers as Accepts: image/webp, */*;q=0.8. The people implementing that change apparently never thought about the impact, so this causes quite a number of API's to return a 415

For more information see: https://code.google.com/p/chromium/issues/detail?id=169182

In the end we modified the server itself, since it would return a 415. On the response side, it should all go well.

这篇关于为什么Chrome for iOS插入图片/ webp内容类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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