Dart BrowserClient POST, not including my cookies

I am doing POST BrowserClient across domains and cannot see my cookies being enabled.

This is the answer I get:

enter image description here

When I send another POST request, I don’t see cookies being enabled:

enter image description here

Going directly to the test page, I see that cookies are enabled:

enter image description hereenter image description here

The Dart code that I use to create the POST is:

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(); }); 

I'm not sure about the Access-Control-Allow-Credentials header, which I include in, with or without it, nothing changes.

Am I skipping server-side headers that should be configured to respond, or is Dartium blocking files with multiple domains?

Learn more about information security and how to set a cookie using a server.

Update: registered request for improvement: https://code.google.com/p/dart/issues/detail?id=23088

Update: the improvement has been completed, now you can do var client = new BrowserClient()..withCredentials=true; based on https://github.com/dart-lang/http/commit/9d76e5e3c08e526b12d545517860c092e089a313

+2
cookies cors dart dartium
Apr 03
source share
1 answer

In order for cookies to be sent to CORS requests, you need to set withCredentials = true . The browser client in the http packet does not support this argument. Instead, you can use HttpRequest from dart:html . See How to use dart-protobuf for an example.

+2
Apr 03 '15 at 8:16
source share
— -



All Articles