简体   繁体   English

Node.js请求节点是否存储HTTPOnly cookie?

[英]Does Node.js Request node store HTTPOnly cookies?

I would like to store the cookies that I receive in a HTTP response and send them to the server in the next HTTP request. 我想存储在HTTP响应中收到的cookie,并在下一个HTTP请求中将它们发送到服务器。 I know that HTTPOnly cookies "dont like" JS. 我知道HTTPOnly cookie“不喜欢” JS。 So does the Request node (using node.js) store the HTTPOnly cookies in jar if set to true? 如果设置为true,那么Request节点(使用node.js)是否将HTTPOnly cookie存储在jar中?

If not how can I work around this, since this is what keeps the session open. 如果没有,我该如何解决,因为这可以使会话保持打开状态。

Thanks for the help!! 谢谢您的帮助!!

Cookies are returned as a part of response headers for most of the HTTP requests made. 对于大多数发出的HTTP请求,Cookie作为响应标头的一部分返回。 So if you happen to use request module to make your HTTP requests, you can console log response and check for the cookies in headers. 因此,如果您碰巧使用请求模块发出HTTP请求,则可以控制台日志响应并检查标头中的cookie。 Thereafter you can use them for your own manipulations and working. 之后,您可以将它们用于自己的操作和工作。 You can do something like below: 您可以执行以下操作:

request({
        method: 'GET',
        url: url,
        headers:<some-req-headers>
    }, function(err, response, body) {
        if (err) {
       console.log(err);
 } else {
       console.log(response.headers);
   }
});

Mostly cookies are part of 'set-cookie' field of response.headers as far as I have observed. 据我所知,cookies通常是response.header的“ set-cookie”字段的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM