【发布时间】:2019-07-16 06:57:45
【问题描述】:
如何在 Flutter API 的标头中添加 set-cookie。我使用了以下 dart 插件:
我正在关注这些链接,但无法添加标题。
以下是我的代码:
Future<Map> getApi() async {
Map<String, String> headers = {};
// HEADERS TO BE ADDED
headers['Set-Cookie'] = "user_image=; Path=/";
headers['Set-Cookie'] = "user_id=Administrator; Path=/";
headers['Set-Cookie'] = "system_user=yes; Path=/";
headers['Set-Cookie'] = "full_name=Administrator; Path=/";
headers['Set-Cookie'] = "sid=123456789; Expires=Mon, 25-Feb-2019 11:01:39 GMT; Path=/";
// API RESPONSE
http.Response response = await http.get(
apiUrl,
headers: headers,
);
// CONVERT TO JSON AND MAP
Map responseBody = convert.jsonDecode(response.body);
return responseBody;
}
【问题讨论】:
标签: http cookies dart flutter http-headers