mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fix to allow blank password for Basic Auth in httprequest node
This commit is contained in:
parent
a3fa6dada5
commit
1f6155f118
@ -104,7 +104,6 @@ function HTTPIn(n) {
|
|||||||
this.warn("Cannot create http-in node when httpNodeRoot set to false");
|
this.warn("Cannot create http-in node when httpNodeRoot set to false");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.registerType("http in",HTTPIn);
|
RED.nodes.registerType("http in",HTTPIn);
|
||||||
|
|
||||||
|
|
||||||
@ -127,7 +126,6 @@ function HTTPOut(n) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.registerType("http response",HTTPOut);
|
RED.nodes.registerType("http response",HTTPOut);
|
||||||
|
|
||||||
function HTTPRequest(n) {
|
function HTTPRequest(n) {
|
||||||
@ -136,12 +134,7 @@ function HTTPRequest(n) {
|
|||||||
var nodeMethod = n.method || "GET";
|
var nodeMethod = n.method || "GET";
|
||||||
var node = this;
|
var node = this;
|
||||||
var credentials = RED.nodes.getCredentials(n.id);
|
var credentials = RED.nodes.getCredentials(n.id);
|
||||||
if (credentials) {
|
|
||||||
this.username = credentials.user;
|
|
||||||
this.password = credentials.password;
|
|
||||||
}
|
|
||||||
this.on("input",function(msg) {
|
this.on("input",function(msg) {
|
||||||
|
|
||||||
var url = msg.url||nodeUrl;
|
var url = msg.url||nodeUrl;
|
||||||
var method = (msg.method||nodeMethod).toUpperCase();
|
var method = (msg.method||nodeMethod).toUpperCase();
|
||||||
var opts = urllib.parse(url);
|
var opts = urllib.parse(url);
|
||||||
@ -150,7 +143,7 @@ function HTTPRequest(n) {
|
|||||||
opts.headers = msg.headers;
|
opts.headers = msg.headers;
|
||||||
}
|
}
|
||||||
if (credentials) {
|
if (credentials) {
|
||||||
opts.auth = credentials.user+":"+credentials.password;
|
opts.auth = credentials.user+":"+(credentials.password||"");
|
||||||
}
|
}
|
||||||
var req = ((/^https/.test(url))?https:http).request(opts,function(res) {
|
var req = ((/^https/.test(url))?https:http).request(opts,function(res) {
|
||||||
res.setEncoding('utf8');
|
res.setEncoding('utf8');
|
||||||
@ -179,11 +172,8 @@ function HTTPRequest(n) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
req.end();
|
req.end();
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.registerType("http request",HTTPRequest);
|
RED.nodes.registerType("http request",HTTPRequest);
|
||||||
|
|
||||||
var querystring = require('querystring');
|
var querystring = require('querystring');
|
||||||
@ -224,5 +214,3 @@ RED.httpAdmin.post('/http-request/:id',function(req,res) {
|
|||||||
res.send(200);
|
res.send(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user