无法在响应标头中接收Set-Cookie

时间:2018-08-30 06:22:54

标签: http web cookies proxy xmlhttprequest

我正在开发一个向服务器发出http请求并希望标头包含Set-Cookie的应用

现在,当我使用代理(例如Charles和mitmproxy)向端点发送HTTP POST请求时,可以在响应头中正确获取Set-Cookie,但是如果我关闭代理并直接发出请求,则其他所有操作相同,但是响应头中缺少Set-Cookie。

请求代理:

POST /_bm/_data HTTP/1.1
Host: www.wsy-test.com
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Content-Type: text/plain;charset=UTF-8
Cookie: anonymousId=4DD95464BB44EF9BB078C84D1F7BB93E
Origin: https://www.wsy-test.com
Referer: https://www.wsy-test.com/landing/
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36

{"request_id":"username"}

代理响应:

HTTP/1.1 201 Created
Content-Length: 22
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type,Authorization
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Origin: *
Access-Control-Allow-Origin: https://www.wsy-test.com
Allow: POST, OPTIONS
Cache-Control: no-cache, no-store
Connection: keep-alive
Content-Type: application/json
Date: Thu, 30 Aug 2018 05:55:12 GMT
Expires: Thu, 30 Aug 2018 05:55:12 GMT
Pragma: no-cache
Set-Cookie: _a=BGYUKVYTCT567VGHJD; expires=Fri, 30 Aug 2019 05:55:12 GMT; max-age=31536000; path=/; domain=.wsy-test.com

{
  "success": true
}

没有代理的请求:

POST /_bm/_data HTTP/1.1
Host: www.wsy-test.com
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Content-Type: text/plain;charset=UTF-8
Cookie: anonymousId=13456C21159F9E36D723EF992BF7999C
Origin: https://www.wsy-test.com
Referer: https://www.wsy-test.com/landing/
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36

{"request_id":"username"}

没有代理的响应:

HTTP/1.1 201 Created
Content-Length: 22
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type,Authorization
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Origin: *
Access-Control-Allow-Origin: https://www.wsy-test.com
Allow: POST, OPTIONS
Cache-Control: no-cache, no-store
Connection: keep-alive
Content-Type: application/json
Date: Thu, 30 Aug 2018 05:56:13 GMT
Expires: Thu, 30 Aug 2018 05:56:13 GMT
Pragma: no-cache

{
  "success": true
}

我在Charles代理中没有特殊配置。这个问题使我困惑了很长时间。

0 个答案:

没有答案