1
0
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:
Dave C-J 2014-03-31 10:28:37 +01:00
parent a3fa6dada5
commit 1f6155f118

View File

@ -104,7 +104,6 @@ function HTTPIn(n) {
this.warn("Cannot create http-in node when httpNodeRoot set to false");
}
}
RED.nodes.registerType("http in",HTTPIn);
@ -127,7 +126,6 @@ function HTTPOut(n) {
}
});
}
RED.nodes.registerType("http response",HTTPOut);
function HTTPRequest(n) {
@ -136,12 +134,7 @@ function HTTPRequest(n) {
var nodeMethod = n.method || "GET";
var node = this;
var credentials = RED.nodes.getCredentials(n.id);
if (credentials) {
this.username = credentials.user;
this.password = credentials.password;
}
this.on("input",function(msg) {
var url = msg.url||nodeUrl;
var method = (msg.method||nodeMethod).toUpperCase();
var opts = urllib.parse(url);
@ -150,7 +143,7 @@ function HTTPRequest(n) {
opts.headers = msg.headers;
}
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) {
res.setEncoding('utf8');
@ -179,11 +172,8 @@ function HTTPRequest(n) {
}
}
req.end();
});
}
RED.nodes.registerType("http request",HTTPRequest);
var querystring = require('querystring');
@ -224,5 +214,3 @@ RED.httpAdmin.post('/http-request/:id',function(req,res) {
res.send(200);
});
});