添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

flutter http request is not back Set-Cookie header

0 人关注

我试图从flutter web的HTTP请求中获取cookie,但它只返回了 Content-type cache-control 。我用 curl 检查了我的请求,它的响应中有 Set-cookie

Flutter代码。

final response = await http.post(
      Uri.parse(Api.BASE_URL),
      headers: <String, String>{
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
      body: {
        'parameter1': Api.TOKEN,
        'parameter2': SOME_PARAMETERS
    response.headers.forEach((k, v) => debugPrint('$k: $v'));

debug print

cache-control: no-cache
content-type: application/json;charset=UTF-8

curl 命令。

curl -X HEAD -i MY_API_ADDRESS --insecure

curl 结果。

Cache-Control: private
Expires: SOME_DATE
Set-Cookie: SOME_COOKIE
Access-Control-Allow-Origin: *
Access-Control-Request-Method: *
Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token
Transfer-Encoding: deflate
Cache-Control: no-cache
Connection: keep-alive