【发布时间】:2012-05-02 09:14:47
【问题描述】:
我正在开发一个需要有状态的 REST Api(没有解决方法,我使用的是没有可序列化对象等的本机库)
此 Rest API 在域 domainA 上的 Web 服务器上公开。 响应包含一个设置为 * 的 Access-Control-Allow-Origin 标头,所以我不需要 JSON-P。 (我不知道这个细节是否在意)。
我在请求 DomainA 的 domainB 上做了这个 API 的 GWT 使用示例。浏览器不会添加之前设置的 cookie。它“无状态”地工作。
样本也必须在 DomainA 上吗? 是否有解决方法或特定标题要设置?
编辑: 我在 Cookie 中设置了一个主域。它不起作用。浏览器仍然没有在下一个请求头中设置 cookie 会话。
请求:
HeadersPreviewResponseCookiesTiming
Request URL:http://subdomainB.mydomain.com/request
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Content-Length:1185
Content-type:application/x-www-form-urlencoded
Host:subdomainB.mydomain.com
Origin:http://subdomainA.mydomain.com
Referer:http://subdomainA.mydomain.com/BLABLABLA
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.8 (KHTML, like Gecko) Chrome/20.0.1105.0 Safari/536.8
回复:
Response Headersview source
Access-Control-Allow-Origin:*
Cache-Control:no-cache, no-store, max-age=0
Connection:Keep-Alive
Content-Language:fr-FR
Content-Type:application/json;charset=UTF-8
Date:Wed, 25 Apr 2012 07:59:03 GMT
Expires:Thu, 01 Jan 1970 00:00:00 GMT, Thu, 01 Jan 1970 00:00:00 GMT
Keep-Alive:timeout=15, max=100
Pragma:no-cache
Server:Jetty(7.5.4.v20111024)
Set-Cookie:JSESSIONID=cookieValue;Path=/;Domain=.mydomain.com
Transfer-Encoding:chunked
【问题讨论】:
-
对此的任何更新。你是怎么解决这个问题的
标签: json http session rest cookies