我试图提供一种具有访问控制允许来源头复制在请求起源标题的内容的HTTP OPTIONS方法的响应。
这显然是不工作的,其原因我想不通。
TL;博士:从选项:回应说:
Access-Control-Allow-Origin: http://10.0.0.105:9294
随后的GET有:
Origin:http://10.0.0.105:9294
Chrome的说:
Origin http://10.0.0.105:9294 is not allowed by Access-Control-Allow-Origin
跆拳道不是?
更多详情...
通过观察在Chrome的开发者工具窗口,请求标题是:
OPTIONS /user/kris HTTP/1.1
Host: 10.0.0.104:8080
Connection: keep-alive
Access-Control-Request-Method: GET
Origin: http://10.0.0.105:9294
User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.75 Safari/537.1
Access-Control-Request-Headers: origin, x-requested-with, content-type, accept
Accept: */*
Referer: http://10.0.0.105:9294/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
响应标题是:
HTTP/1.0 200 OK
Date: Mon, 13 Aug 2012 11:23:45 GMT
Server: WSGIServer/0.1 Python/2.7.3
Content-Length: 0
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, HEAD, OPTIONS
Access-Control-Max-Age: 10
Access-Control-Allow-Origin: http://10.0.0.105:9294
Access-Control-Allow-Headers: X-Requested-With, Authorization, X-Huzu-User, Content-Type, Accept
Content-Type: text/html; charset=UTF-8
jQuery的发送它的OPTIONS请求,并得到上述响应后,2点奇数的事情发生。 响应中(这是一个200)示出了在显影剂控制台作为一个错误:
OPTIONS http://10.0.0.104:8080/user/kris 200 (OK)
这后一GET请求被拒绝。 错误控制台:
XMLHttpRequest cannot load http://10.0.0.104:8080/user/kris. Origin http://10.0.0.105:9294 is not allowed by Access-Control-Allow-Origin.
我不明白为什么不能。 我究竟做错了什么?