2015-04-03 69 views
2

我正在通过域执行BrowserClient POST,但未看到包含我的Cookie。Dart BrowserClient POST不包含我的cookies

我得到了响应:

enter image description here

当我发送另一个POST请求,我没有看到被列入饼干:

enter image description here

直去在测试页面中,我可以看到包含的曲奇:

enter image description here enter image description here

达特代码,我用它来做一个POST:

var client = new BrowserClient(); 

client.post(url, body: request, headers:{"Content-Type" : "application/json", "Access-Control-Allow-Credentials":"true"}).then((res) { 
     if (res.statusCode == 200) { 
     var response = JSON.decode(res.body); 

     callback(response); 
     } else { 
     print(res.body); 
     print(res.reasonPhrase); 
     } 
    }).whenComplete(() { 
     client.close(); 
    }); 

不知道的访问控制允许的凭据头,我,包括有或没有它,没有什么变化。

我是否在服务器端丢失了需要在响应中设置的标题,或者Dartium是否阻止了跨域Cookie?

有关Information Security的更多详细信息以及通过服务器设置Cookie的原因。

更新:改进请求记录:https://code.google.com/p/dart/issues/detail?id=23088

更新:强化执行,应该现在是基于 https://github.com/dart-lang/http/commit/9d76e5e3c08e526b12d545517860c092e089a313

+1

我想你需要在你的发布请求中设置'withCredentials = true',但是我还没有发现如何用http包的请求来做到这一点(就像在http://stackoverflow.com/questions/中一样21770445或http://stackoverflow.com/questions/16939328)。 – 2015-04-03 06:51:37

+1

我可以看到在angular.dart中做了特别的规定,但在浏览器客户端中没有这样做https://github.com/dsalsbury/angular.dart/commit/9ff1bc321cd201bee09f8420c42e61632481ffb7 – 2015-04-03 07:01:14

+0

如果angular.dart正在这样做,肯定它必须调用引擎盖下的标准dart库还是angular.dart都有自己的BrowserClient类库? – 2015-04-03 07:29:39

回答

2

饼干被送到CORS请求能够做到var client = new BrowserClient()..withCredentials=true;,你需要设置withCredentials = truehttp包中的浏览器客户端不支持此参数。您可以改用dart:html中的HttpRequest。例如, 请参阅How to use dart-protobuf

+1

已经为http包提供了一个修复请求。希望很快出版。 – 2015-04-03 17:17:29

+0

我可以在Github上看到修复程序,修复程序发布的通常时间跨度是多少?如果它在一周左右,我会稍微等一下,否则我会遵循dart-protobuf示例,这样我至少可以完成我的身份验证层。 – 2015-04-08 05:42:55

+0

根据pub.dartlang.org上的更改日志,两天前发布了包含此更改的版本。 – 2015-04-08 05:44:42