mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00: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.responseType = 'buffer';
|
||||||
opts.maxRedirects = 21;
|
opts.maxRedirects = 21;
|
||||||
opts.cookieJar = new CookieJar();
|
opts.cookieJar = new CookieJar();
|
||||||
|
opts.ignoreInvalidCookies = true;
|
||||||
opts.forever = nodeHTTPPersistent;
|
opts.forever = nodeHTTPPersistent;
|
||||||
if (msg.requestTimeout !== undefined) {
|
if (msg.requestTimeout !== undefined) {
|
||||||
if (isNaN(msg.requestTimeout)) {
|
if (isNaN(msg.requestTimeout)) {
|
||||||
@ -181,7 +182,7 @@ module.exports = function(RED) {
|
|||||||
if (opts.headers.hasOwnProperty('cookie')) {
|
if (opts.headers.hasOwnProperty('cookie')) {
|
||||||
var cookies = cookie.parse(opts.headers.cookie, {decode:String});
|
var cookies = cookie.parse(opts.headers.cookie, {decode:String});
|
||||||
for (var name in cookies) {
|
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;
|
delete opts.headers.cookie;
|
||||||
}
|
}
|
||||||
@ -194,13 +195,13 @@ module.exports = function(RED) {
|
|||||||
} else if (typeof msg.cookies[name] === 'object') {
|
} else if (typeof msg.cookies[name] === 'object') {
|
||||||
if(msg.cookies[name].encode === false){
|
if(msg.cookies[name].encode === false){
|
||||||
// If the encode option is false, the value is not encoded.
|
// 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 {
|
} else {
|
||||||
// The value is encoded by encodeURIComponent().
|
// 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 {
|
} else {
|
||||||
opts.cookieJar.setCookie(cookie.serialize(name, msg.cookies[name]), url);
|
opts.cookieJar.setCookie(cookie.serialize(name, msg.cookies[name]), url, {ignoreError: true});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,11 +221,11 @@ module.exports = function(RED) {
|
|||||||
if (this.credentials.user) {
|
if (this.credentials.user) {
|
||||||
// opts.username = this.credentials.user;
|
// opts.username = this.credentials.user;
|
||||||
cred = this.credentials.user
|
cred = this.credentials.user
|
||||||
}
|
}
|
||||||
if (this.credentials.password) {
|
if (this.credentials.password) {
|
||||||
// opts.password = this.credentials.password;
|
// opts.password = this.credentials.password;
|
||||||
cred += ":" + this.credentials.password
|
cred += ":" + this.credentials.password
|
||||||
}
|
}
|
||||||
// build own basic auth header
|
// build own basic auth header
|
||||||
opts.headers.Authorization = "Basic " + Buffer.from(cred).toString("base64");
|
opts.headers.Authorization = "Basic " + Buffer.from(cred).toString("base64");
|
||||||
} else if (this.authType === "digest") {
|
} else if (this.authType === "digest") {
|
||||||
@ -386,7 +387,7 @@ module.exports = function(RED) {
|
|||||||
http: new HttpProxyAgent(proxyOptions),
|
http: new HttpProxyAgent(proxyOptions),
|
||||||
https: new HttpsProxyAgent(proxyOptions)
|
https: new HttpsProxyAgent(proxyOptions)
|
||||||
};
|
};
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
node.warn("Bad proxy url: "+ prox);
|
node.warn("Bad proxy url: "+ prox);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user