情景:
请注意:
JS代码基本上就是这个
var url = "http://xxxxxx/zot";
var oReq = new XMLHttpRequest();
oReq.onerror = function() {
// I received the error
};
oReq.onload = function(e) {
// Not reached
};
oReq.open("GET", url, true);
oReq.send();
标题是第一次请求吐出:
HTTP/1.1 307 Temporary Redirect
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: connection,host,accept-language,accept-encoding,accept-charset,user-agent,origin,cache-control,pragma,referer,origin,X-Requested-With,x-requested-with,accept-charset,x-wap-profile,x-getzip, Access-Control-Allow-Origin,X-HTTP-Method-Override,Content-Type,Authorization,Accept
Access-Control-Allow-Methods: GET, POST, OPTIONS
Location: http://10.90.7.10:3030/r/vast
Date: Fri, 11 Apr 2014 09:40:01 GMT
Connection: keep-alive
(尝试删除所有这些,部分等等)
答案 0 :(得分:2)
我发现了这个问题。遗憾的是,WebViews倾向于在每个请求中发送自定义标头,并且该事实将触发具有预检类型请求的 CORS。但我有一个重定向,标准禁止明确禁止预检请求(http://www.w3.org/TR/cors/#cross-origin-request-with-preflight-0,第3节)
如果响应的HTTP状态代码不在2xx范围内[则]应用网络错误步骤。
例如,我的XPeria T正在发送x-wap-profile
和x-getzip
,但也发送x-requested-with
。