Support cookiejar for http-request node

Hello,

I'd like to develop the following feature.

「Return accumulated cookies if redirects are followed - (tbc: may not be the right answer)」

request package that Node-RED currently uses has a problem that does not accumulate the cookies returned from original URLs of redirection. This problem is discussed in the issues of the 'request' package, but has not been yet solved.

With regard to (tbc: may not be the right answer), I checked the behavior of several browsers.
Chrome and Firefox accumulates both the cookies of an original server and an redirected server.
So it would be better that the http-request node outputs the cookies of both servers instead of outputing only the cookie of an redirected server.

Although using cookiejar can solve the above problem, we need to consider how to output the accumulated cookies from http-request node.
There are three options.

  1. Replace the contents of msg.responseCookies.
  2. Add cookiejar in msg.
  3. Add _cookiejar property in the existing msg.responseCookies property.

Option 1 is not preferable because of the backward compatibility.
Option 2 looks a little bit strange because there are two cookie parameters in msg.
So I think that option 3 is the good choice.
Could you give me your comments or alternative idea?

FYI, The following JSON data is a sample output of cookiejar. domain parameter is included.

[
    {
        "key": "key1",
        "value": "value1",
        "domain": "127.0.0.1",
        "path": "/",
        "hostOnly": true,
        "creation": "2018-07-05T02:04:04.218Z",
        "lastAccessed": "2018-07-05T02:04:04.218Z"
    },
    {
        "key": "key2",
        "value": "value2",
        "domain": "localhost",
        "path": "/",
        "hostOnly": true,
        "creation": "2018-07-05T02:04:04.228Z",
        "lastAccessed": "2018-07-05T02:04:04.228Z"
    }
]

Thanks
Kazuki

I posted a pull request regarding this feature.

Thanks,
Kazuki