I try to get the cookie from an HTTP request in flutter web but It just back Content-type
and cache-control
. I checked my request with curl
and it had Set-cookie
in the response.
Flutter code:
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
command:
curl -X HEAD -i MY_API_ADDRESS --insecure
curl
result:
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
X-Frame-Options: sameorigin
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Wed, 24 Nov 2021 12:37:00 GMT