NodeJS 如何在curl请求中传递cookie

a2mppw5e  于 2023-03-08  发布在  Node.js
关注(0)|答案(1)|浏览(173)

我必须使用curl发送请求,在那个请求中我需要从下面的响应中设置cookie。所以有人能帮我如何传递curl请求中的所有cookie吗

HTTP/1.1 200 OK  
X-Powered-By: Express  
Access-Control-Allow-Origin:undefined  
Access-Control-Allow-Credentials: true 
Access-Control-Allow-Methods: GET,POST,OPTIONS 
Access-Control-Allow-Headers: Content-Type  
set-cookie: SESSIONID=agpuB2CqPDhkupxfbrZXCR; Path=/ABC  
set-cookie: bac_cookie=7959aacd5cc48;Domain=abc.com;Expires=Mon, 05-Dec-2016 18:47:42 GMT; Path=/
set-cookie: beID=0023T21; Domain=abc.com; Expires=Mon,05-Dec-2016 18:47:42 GMT; Path=/  
set-cookie:USER_JSESSIONID=agpuB2CqPDhkupxfbrJlbXF3;Domain=abc.com;Expires=Mon, 05-Dec-2016 18:47:42 GMT; Path=/ 
set-cookie:bac_user_info="UserName|UserLName|UserMailId"; Version=1;Domain=abc.com; Max-Age=3600; Path=/  
set-cookie: beID=0023T21; Domain=abc.com; Expires=Mon, 05-Dec-2016 18:47:42 GMT; Path=/ 
set-cookie:NSC_WB2-CF-8080=ffffffff09ae530a45525d5f4f58455e445a4a4229a0;path=/;httponly
Content-Type: application/json; charset=utf-8  
Content-Length: 131 
ETag: W/"83-+Jfk31hxbwmLWd1hTlIO1Q"  
Date: Mon, 05 Dec 2016 17:47:42 GMT  
Connection: abc
pqwbnv8z

pqwbnv8z1#

如果您想发送多个cookie,只需使用;分隔符将它们分隔开。

curl -v --cookie "TOKEN1=Yes;TOKEN2=no" "http://127.0.0.1:5000"

相关问题