我在客户端上使用angular.dart在服务器端使用dart开发一个应用程序。我已经写了一个登录休息入口点,并且想要设置cookie头是响应中的,但未设置cookie。
set-cookie:app-user=533c1470a2658184a7625d7d; Expires=Tue, 8 Apr 2014 9:15:47 GMT; Domain=.ballr.eu; Path=/
set-cookie:app-tokn=530fa71b615e168787a7cb5b5c589a5601065e1e3f921d4b770c784394de3a42; Expires=Tue, 8 Apr 2014 9:15:47 GMT; Domain=.ballr.eu; Path=/
我尝试检查标题或cookie中设置的值,但我认为是不错的
标题:
request.response..statusCode=HttpStatus.OK
..headers.set(HttpHeaders.CONTENT_TYPE, 'text/plain: charset=UTF-8')
..headers.add("Access-Control-Allow-Methods", "OPTIONS, GET, POST, PUT, DELETE")
..headers.add("Access-Control-Allow-Headers", "origin, x-requested-with, content-type, accept")
..headers.add("Access-Control-Allow-Origin", "*");
cookies:
static setCookie(HttpRequest request, String key, String value, DateTime duration) =>
request.response.cookies.add(new Cookie(key, value)..path = '/'
..expires = duration
..domain = '.app.eu');
[我在stackoverflow和google group上关注了一些线程,我认为这是“ withCredientals”的问题,我在另一个projet(angular / Java)中设置了这个值,但在angular.dart上找不到此参数。
您能帮我找到它还是有一些想法吗?
感谢您的帮助/时间
var request = new HttpRequest()
..open("POST", uri.toString(), async: true)
..withCredentials = true // seems to be necessary so that cookies are sent
编辑我想念这与Angular有关。这需要稍微不同的方法。如果使用Angular
http
服务,则具有参数class MyController { Http _http; MyController(this._http) { _http.getString('someurl', withCredentials: true).then((e) => ...); // or _http.request('someurl', method: 'POST', withCredentials: true).then((e) => ...); } }