我在客户端使用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组上关注了一些线程,我认为这是“withCredientals”的一个问题,我在另一个项目(angular / Java)中设置了一个值但是我没有在angular.dart上找到这个参数。 / p>
你能帮我找到它还是有想法?
感谢您的帮助/时间
答案 0 :(得分:0)
我不确定我是否理解你的问题,但也许这就是你要找的:
(在客户端)
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) => ...);
}
}