[英]Why does Chrome for iOS insert image/webp content-type?
I have a mobile web app that is making an AJAX request via $.get(). 我有一个通过$ .get()发出AJAX请求的移动Web应用程序。 The request succeeds for Safari iOS, but fails for Chrome for iOS with status 0 and statusText "error".
对于Safari iOS,该请求成功,但对于状态为0和statusText为“错误”的Chrome for iOS,该请求失败。
Using tcpdump on my server, I can see that Safari sends/receives the following headers: 在服务器上使用tcpdump,我可以看到Safari发送/接收以下标头:
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": Chrome浏览器(iOS版)将哑剧类型“ image / webp”添加到传出的Accept:标头中,返回的Content-Type为“ 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. 通过阅读jQuery代码,看起来$ .get()仅解析AJAX响应中的某些内容类型,因此我认为图像模仿类型只是被拒绝,从而导致“错误”状态。
In the request from Chrome for iOS as it arrives on my server, there's also this header: 当Chrome for iOS到达我的服务器时,它发出的请求中也包含以下标头:
Via: 1.1 Chrome-Compression-Proxy 通过: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 ). ...,这表示Chrome for iOS已将请求发送到Google代理服务器以为请求提供服务(信息https://support.google.com/chrome/answer/3517349?hl=zh_CN )。 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?
好像此代理服务器正在设置额外的内容类型,并且该内容类型以某种方式在返回时以image / webp的形式返回? The server code is RESTful Spring 3;
服务器代码是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".
我确实在控制器代码中将内容类型设置为“文本/纯文本”,但是不知何故,它仍然以“ 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.
我需要具有“文本/纯文本”的返回Content-Type才能将数据正确返回到我的应用程序。 This request works correctly on Chrome for Android as well AFAIK, haven't done a tcpdump for that, but the app works correctly;
此请求可以在Android版Chrome和AFAIK上正常运行,尚未对此进行tcpdump,但该应用正常运行; only fails on Chrome for iOS.
仅在iOS版Chrome上失败。
We are encountering the same issue: Chrome for iOS prefers webp, so it sends its headers as Accepts: image/webp, */*;q=0.8
. 我们遇到了同样的问题:Chrome for iOS首选webp,因此它将标头发送为
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 实施此更改的人员显然从未考虑过影响,因此这导致许多API返回415
For more information see: https://code.google.com/p/chromium/issues/detail?id=169182 有关更多信息,请参见: 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. 最后,我们修改了服务器本身,因为它将返回415。在响应方面,它应该运行良好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.