CORS请求失败在Chrome仅当有头CORS、Chrome

2023-09-10 16:07:06 作者:因为我的勇气

我想发送简单的CORS请求,它使用会话密钥进行授权的外部应用程序服务器。

I'm trying to send simple CORS request to external application server which uses session key for authorization.

$.ajax({
    type: "GET",
    url: "https://192.168.1.72:8442/api/file/",
    headers: {"Authorization": "3238562439e44fcab4036a24a1e6b0fb"}
});

它工作正常,在Firefox 18,歌剧12.12和Rekonq 2.0(使用也WebKit的),但在谷歌浏览器无法正常工作(试过版本21和24)。在谷歌浏览器就显示选项资源未能网络听诊器和应用服务器负载没有得到任何请求。我试过的jQuery 1.8.3和1.9.0。

It works fine in Firefox 18, Opera 12.12 and Rekonq 2.0 (uses also WebKit) but doesn't work in Google Chrome (tried versions 21 and 24). In Google Chrome it shows OPTIONS Resource failed to load in Network Inspector and application server doesn't get any request. I've tried jQuery 1.8.3 and 1.9.0.

Request URL:https://192.168.1.72:8442/api/file/
Request Headers
Access-Control-Request-Headers:accept, authorization, origin
Access-Control-Request-Method:GET
Cache-Control:no-cache
Origin:https://192.168.1.72:8480
Pragma:no-cache

如果我从请求删除页眉然后我收到401也是在谷歌Chrome和它能够访问资源的情况下,授权被禁止的应用程序服务器。它并不重要的报头被发送。只有头,我能够发送是{内容类型:纯/文本}。所有其它的头名称/值给出在我上面提到的所有的浏览器在谷歌浏览器的错误,但工作。

If I remove headers from the request then I receive 401 also in Google Chrome and it's able to access the resource in case of authorization is disabled on application server. It doesn't matter which headers are sent. Only header I'm able to send is {"Content-Type": "plain/text"}. All other header names/values give an error in Google Chrome but work in all browsers I mentioned above.

为什么谷歌Chrome浏览器不会在CORS请求处理头?

Why Google Chrome doesn't handle headers in CORS request?

推荐答案

这是在谷歌Chrome浏览器的一个错误:http://$c$c.google.com/p/chromium/issues/detail?id=96007.

It's a bug in Google Chrome: http://code.google.com/p/chromium/issues/detail?id=96007.