我尝试过,https.request
但是当我想访问 cookie 响应时,这不会出现在资源标题中。HTTP/HTTPS。
示例代码:
let https = require('https');
https.request({
rejectUnauthorized: false,
hostname: 'example.com',
port: '443',
path: '/example.html',
method: 'POST',
headers: {
"Connection": "keep-alive",
"Accept-Encoding": "gzip, deflate, br",
"Upgrade-Insecure-Requests": "1",
"Content-Type": "application/x-www-form-urlencoded",
"Cache-Control": "no-cache",
"Pragma": "no-cache",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"Accept-Language": "es-ES,es;q=0.8",
}
}, (res: any) => {
console.log('headers', res.headers); // this does not show 'set-cookie' property.
})
支持 Cookies 吗?谢谢
PS:我typescript
用来编写和ts-node
运行这个脚本。