1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Replace tabs with 4 space indent.

This commit is contained in:
Mark Hindess 2014-07-23 22:10:27 +01:00
parent 6c4611a934
commit d7445a5bb9

View File

@ -17,36 +17,36 @@
var RED = require(process.env.NODE_RED_HOME+"/red/red"); var RED = require(process.env.NODE_RED_HOME+"/red/red");
function HttpGet(n) { function HttpGet(n) {
RED.nodes.createNode(this,n); RED.nodes.createNode(this,n);
this.baseurl = n.baseurl || ""; this.baseurl = n.baseurl || "";
this.append = n.append || ""; this.append = n.append || "";
var node = this; var node = this;
if (this.baseurl.substring(0,5) === "https") { var http = require("https"); } if (this.baseurl.substring(0,5) === "https") { var http = require("https"); }
else { var http = require("http"); } else { var http = require("http"); }
this.on("input", function(msg) { this.on("input", function(msg) {
msg._payload = msg.payload; msg._payload = msg.payload;
//util.log("[httpget] "+this.baseurl+msg.payload+this.append); //util.log("[httpget] "+this.baseurl+msg.payload+this.append);
http.get(this.baseurl+msg.payload+this.append, function(res) { http.get(this.baseurl+msg.payload+this.append, function(res) {
node.log("Http response: " + res.statusCode); node.log("Http response: " + res.statusCode);
msg.rc = res.statusCode; msg.rc = res.statusCode;
msg.payload = ""; msg.payload = "";
if ((msg.rc != 200) && (msg.rc != 404)) { if ((msg.rc != 200) && (msg.rc != 404)) {
node.send(msg); node.send(msg);
} }
res.setEncoding('utf8'); res.setEncoding('utf8');
res.on('data', function(chunk) { res.on('data', function(chunk) {
msg.payload += chunk; msg.payload += chunk;
}); });
res.on('end', function() { res.on('end', function() {
node.send(msg); node.send(msg);
}); });
}).on('error', function(e) { }).on('error', function(e) {
//node.error(e); //node.error(e);
msg.rc = 503; msg.rc = 503;
msg.payload = e; msg.payload = e;
node.send(msg); node.send(msg);
}); });
}); });
} }
RED.nodes.registerType("httpget",HttpGet); RED.nodes.registerType("httpget",HttpGet);