How do I create a HTTP Client Request with a cookie?

后端 未结 3 973
无人及你
无人及你 2020-12-07 18:29

I\'ve got a node.js Connect server that checks the request\'s cookies. To test it within node, I need a way to write a client request and attach a cookie to it. I understa

3条回答
  •  春和景丽
    2020-12-07 19:17

    You can do that using Requestify, a very simple and cool HTTP client I wrote for nodeJS, it support easy use of cookies and it also supports caching.

    To perform a request with a cookie attached just do the following:

    var requestify = require('requestify');
    requestify.post('http://google.com', {}, {
        cookies: {
            sessionCookie: 'session-cookie-data'   
        }
    });
    

提交回复
热议问题