2 * Copyright 2013 IBM Corp.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 var RED = require(process.env.NODE_RED_HOME+"/red/red");
20 RED.nodes.createNode(this,n);
21 this.warn("This node has been deprecated and will be deleted in a future release. Please update your flow to use the 'http request' node.");
22 this.baseurl = n.baseurl || "";
23 this.append = n.append || "";
25 if (this.baseurl.substring(0,5) === "https") { var http = require("https"); }
26 else { var http = require("http"); }
27 this.on("input", function(msg) {
28 msg._payload = msg.payload;
29 //util.log("[httpget] "+this.baseurl+msg.payload+this.append);
30 http.get(this.baseurl+msg.payload+this.append, function(res) {
31 node.log("Http response: " + res.statusCode);
32 msg.rc = res.statusCode;
34 if ((msg.rc != 200) && (msg.rc != 404)) {
37 res.setEncoding('utf8');
38 res.on('data', function(chunk) {
41 res.on('end', function() {
44 }).on('error', function(e) {
53 RED.nodes.registerType("httpget",HttpGet);