Firefox 3 CORS XMLHTTPRequest似乎不工作 [英] Firefox 3 CORS XMLHTTPRequest doesn't seem to work

查看:374
本文介绍了Firefox 3 CORS XMLHTTPRequest似乎不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现了一个REST服务,我从一个javascript应用程序在不同的域中调用。

I implemented a REST service, which I'm calling from a javascript application on a different domain.

我试图做一个GET请求,

I'm attempting to do a GET request, and setting the Authorization: header, with a custom authentication scheme.

由于我设置了一个自定义标题,Firefox将从预检OPTIONS请求开始。这个请求看起来像这样(简化):

Because I'm setting a custom header, Firefox will start with a preflight OPTIONS request. This request looks like this (simplified):

OPTIONS /v1/articles HTTP/1.1
Host: example.org
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13 FirePHP/0.5
Origin: http://example.com
Access-Control-Request-Method: GET
Access-Control-Request-Headers: authorization

我的回答如下:

HTTP/1.1 200 OK
Date: Wed, 15 Dec 2010 16:36:47 GMT
Server: Apache/2.2.9 (Debian) PHP/5.3.3-0.dotdeb.1 with Suhosin-Patch mod_vhost_hash_alias/1.0
X-Powered-By: PHP/5.3.3-0.dotdeb.1
Access-Control-Allow-Origin: http://example.com
Access-Control-Request-Method: GET,POST,PUT,DELETE,HEAD,OPTIONS
Access-Control-Request-Headers: Authorization, X-Authorization
Content-Length: 2
Content-Type: application/json

之后,实际的GET请求不会执行。我担心我在回应时犯了一个错误,但我似乎无法找到它。

After this, the actual GET request is simply not performed. I'm worried I made a mistake in my response, but I can't seem to spot it.

另一个问题是我找不到办法一个详细的错误消息。如您所见,我也尝试了X-Authorization而不是授权。

The other problem is that I've found no way to get a detailed error message. As you can see, I also tried X-Authorization instead of Authorization.

我的问题:

我的回答有问题吗?如何查找有关此问题的更多详情?

Is there something wrong with my response? How can I find more details about the problem?

谢谢!

推荐答案

我需要一个新的看看这个。第二天早上,我意识到正确的头是:

I needed a fresh look at this. The next morning I realized the correct headers are:

Access-Control-Allow-Methods: GET,POST,PUT,DELETE,HEAD,OPTIONS
Access-Control-Allow-Headers: Authorization, X-Authorization

这篇关于Firefox 3 CORS XMLHTTPRequest似乎不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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