mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
HTTP Request node - ignore invalid cookies rather than fail request
Fixes #3075 Keeps behaviour consistent with the request module
This commit is contained in:
parent
68fb5089f8
commit
6750be3ec9
@ -121,6 +121,7 @@ module.exports = function(RED) {
|
||||
opts.responseType = 'buffer';
|
||||
opts.maxRedirects = 21;
|
||||
opts.cookieJar = new CookieJar();
|
||||
opts.ignoreInvalidCookies = true;
|
||||
opts.forever = nodeHTTPPersistent;
|
||||
if (msg.requestTimeout !== undefined) {
|
||||
if (isNaN(msg.requestTimeout)) {
|
||||
@ -181,7 +182,7 @@ module.exports = function(RED) {
|
||||
if (opts.headers.hasOwnProperty('cookie')) {
|
||||
var cookies = cookie.parse(opts.headers.cookie, {decode:String});
|
||||
for (var name in cookies) {
|
||||
opts.cookieJar.setCookie(cookie.serialize(name, cookies[name], {encode:String}), url);
|
||||
opts.cookieJar.setCookie(cookie.serialize(name, cookies[name], {encode:String}), url, {ignoreError: true});
|
||||
}
|
||||
delete opts.headers.cookie;
|
||||
}
|
||||
@ -194,13 +195,13 @@ module.exports = function(RED) {
|
||||
} else if (typeof msg.cookies[name] === 'object') {
|
||||
if(msg.cookies[name].encode === false){
|
||||
// If the encode option is false, the value is not encoded.
|
||||
opts.cookieJar.setCookie(cookie.serialize(name, msg.cookies[name].value, {encode: String}), url);
|
||||
opts.cookieJar.setCookie(cookie.serialize(name, msg.cookies[name].value, {encode: String}), url, {ignoreError: true});
|
||||
} else {
|
||||
// The value is encoded by encodeURIComponent().
|
||||
opts.cookieJar.setCookie(cookie.serialize(name, msg.cookies[name].value), url);
|
||||
opts.cookieJar.setCookie(cookie.serialize(name, msg.cookies[name].value), url, {ignoreError: true});
|
||||
}
|
||||
} else {
|
||||
opts.cookieJar.setCookie(cookie.serialize(name, msg.cookies[name]), url);
|
||||
opts.cookieJar.setCookie(cookie.serialize(name, msg.cookies[name]), url, {ignoreError: true});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user