mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Remove deprecated nodes
This commit is contained in:
		@@ -1,56 +0,0 @@
 | 
			
		||||
<!--
 | 
			
		||||
  Copyright 2013 IBM Corp.
 | 
			
		||||
 | 
			
		||||
  Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
  you may not use this file except in compliance with the License.
 | 
			
		||||
  You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
  http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
  Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
  distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
  See the License for the specific language governing permissions and
 | 
			
		||||
  limitations under the License.
 | 
			
		||||
-->
 | 
			
		||||
 | 
			
		||||
<script type="text/x-red" data-template-name="imap">
 | 
			
		||||
    <div class="form-row node-input-repeat">
 | 
			
		||||
        <label for="node-input-repeat"><i class="fa fa-repeat"></i>Repeat (S)</label>
 | 
			
		||||
        <input type="text" id="node-input-repeat" placeholder="300">
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="form-row">
 | 
			
		||||
        <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
 | 
			
		||||
        <input type="text" id="node-input-name" placeholder="Name">
 | 
			
		||||
    </div>
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<script type="text/x-red" data-help-name="imap">
 | 
			
		||||
    <p>Repeatedly gets a <b>single email</b> from an IMAP server and forwards on as a msg if not already seen.</p>
 | 
			
		||||
    <p>The subject is loaded into <b>msg.topic</b> and <b>msg.payload</b> is the plain text body.
 | 
			
		||||
       If there is text/html then that is returned in <b>msg.html</b>. <b>msg.from</b> and <b>msg.date</b> are also set if you need them.</p>
 | 
			
		||||
    <p>Uses the imap module - you also need to pre-configure your email settings in a file emailkeys.js as per below.</p>
 | 
			
		||||
    <p><pre>module.exports = { service: "Gmail", user: "blahblah@gmail.com", pass: "password", server: "imap.gmail.com", port: "993" }</pre></p>
 | 
			
		||||
    <p>This <b>must</b> be located in the directory <b>above</b> node-red.</p>
 | 
			
		||||
    <p><b>Note:</b> this node <i>only</i> gets the most recent single email from the inbox, so set the repeat (polling) time appropriately.</p>
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript">
 | 
			
		||||
    RED.nodes.registerType('imap',{
 | 
			
		||||
        category: 'deprecated',
 | 
			
		||||
        color:"#c7e9c0",
 | 
			
		||||
        defaults: {
 | 
			
		||||
            repeat: {value:"300",required:true},
 | 
			
		||||
            name: {value:""}
 | 
			
		||||
        },
 | 
			
		||||
        inputs:0,
 | 
			
		||||
        outputs:1,
 | 
			
		||||
        icon: "envelope.png",
 | 
			
		||||
        label: function() {
 | 
			
		||||
            return this.name||"IMAP";
 | 
			
		||||
        },
 | 
			
		||||
        labelStyle: function() {
 | 
			
		||||
            return (this.name||!this.topic)?"node_label_italic":"";
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
</script>
 | 
			
		||||
@@ -1,139 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright 2013 IBM Corp.
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 **/
 | 
			
		||||
 | 
			
		||||
var RED = require(process.env.NODE_RED_HOME+"/red/red");
 | 
			
		||||
var Imap = require('imap');
 | 
			
		||||
var util = require('util');
 | 
			
		||||
 | 
			
		||||
try {
 | 
			
		||||
    var emailkey = RED.settings.email || require(process.env.NODE_RED_HOME+"/../emailkeys.js");
 | 
			
		||||
} catch (err) {
 | 
			
		||||
    //util.log("[61-imap.js] Info : No Email credentials found.");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if (emailkey) {
 | 
			
		||||
    var imap = new Imap({
 | 
			
		||||
        user: emailkey.user,
 | 
			
		||||
        password: emailkey.pass,
 | 
			
		||||
        host: emailkey.server||"imap.gmail.com",
 | 
			
		||||
        port: emailkey.port||"993",
 | 
			
		||||
        tls: true,
 | 
			
		||||
        tlsOptions: { rejectUnauthorized: false }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    function openInbox(cb) {
 | 
			
		||||
        imap.openBox('INBOX', true, cb);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function ImapNode(n) {
 | 
			
		||||
    RED.nodes.createNode(this,n);
 | 
			
		||||
    this.warn("This node has been deprecated and will be deleted in a future release. Please update your flow to use the 'e-mail in' node.");
 | 
			
		||||
    this.name = n.name;
 | 
			
		||||
    this.repeat = n.repeat * 1000 || 300000;
 | 
			
		||||
    var node = this;
 | 
			
		||||
    this.interval_id = null;
 | 
			
		||||
    var oldmail = {};
 | 
			
		||||
 | 
			
		||||
    if (!isNaN(this.repeat) && this.repeat > 0) {
 | 
			
		||||
        node.log("repeat = "+this.repeat);
 | 
			
		||||
        this.interval_id = setInterval( function() {
 | 
			
		||||
            node.emit("input",{});
 | 
			
		||||
        }, this.repeat );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this.on("input", function(msg) {
 | 
			
		||||
        if (imap) {
 | 
			
		||||
            imap.once('ready', function() {
 | 
			
		||||
                var pay = {};
 | 
			
		||||
                openInbox(function(err, box) {
 | 
			
		||||
                    if (box.messages.total > 0) {
 | 
			
		||||
                        var f = imap.seq.fetch(box.messages.total + ':*', { bodies: ['HEADER.FIELDS (FROM SUBJECT DATE)','TEXT'] });
 | 
			
		||||
                        f.on('message', function(msg, seqno) {
 | 
			
		||||
                            node.log('message: #'+ seqno);
 | 
			
		||||
                            var prefix = '(#' + seqno + ') ';
 | 
			
		||||
                            msg.on('body', function(stream, info) {
 | 
			
		||||
                                var buffer = '';
 | 
			
		||||
                                stream.on('data', function(chunk) {
 | 
			
		||||
                                    buffer += chunk.toString('utf8');
 | 
			
		||||
                                });
 | 
			
		||||
                                stream.on('end', function() {
 | 
			
		||||
                                    if (info.which !== 'TEXT') {
 | 
			
		||||
                                        pay.from = Imap.parseHeader(buffer).from[0];
 | 
			
		||||
                                        pay.topic = Imap.parseHeader(buffer).subject[0];
 | 
			
		||||
                                        pay.date = Imap.parseHeader(buffer).date[0];
 | 
			
		||||
                                    } else {
 | 
			
		||||
                                        var parts = buffer.split("Content-Type");
 | 
			
		||||
                                        for (var p in parts) {
 | 
			
		||||
                                            if (parts[p].indexOf("text/plain") >= 0) {
 | 
			
		||||
                                                pay.payload = parts[p].split("\n").slice(1,-2).join("\n").trim();
 | 
			
		||||
                                            }
 | 
			
		||||
                                            if (parts[p].indexOf("text/html") >= 0) {
 | 
			
		||||
                                                pay.html = parts[p].split("\n").slice(1,-2).join("\n").trim();
 | 
			
		||||
                                            }
 | 
			
		||||
                                        }
 | 
			
		||||
                                        //pay.body = buffer;
 | 
			
		||||
                                    }
 | 
			
		||||
                                });
 | 
			
		||||
                            });
 | 
			
		||||
                            msg.on('end', function() {
 | 
			
		||||
                                //node.log('Finished: '+prefix);
 | 
			
		||||
                            });
 | 
			
		||||
                        });
 | 
			
		||||
                        f.on('error', function(err) {
 | 
			
		||||
                            node.warn('fetch error: ' + err);
 | 
			
		||||
                        });
 | 
			
		||||
                        f.on('end', function() {
 | 
			
		||||
                            if (JSON.stringify(pay) !== oldmail) {
 | 
			
		||||
                                node.send(pay);
 | 
			
		||||
                                oldmail = JSON.stringify(pay);
 | 
			
		||||
                                node.log('sent new message: '+pay.topic);
 | 
			
		||||
                            }
 | 
			
		||||
                            else { node.log('duplicate not sent: '+pay.topic); }
 | 
			
		||||
                            imap.end();
 | 
			
		||||
                        });
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        // node.log("you have achieved inbox zero");
 | 
			
		||||
                        imap.end();
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
            });
 | 
			
		||||
            imap.connect();
 | 
			
		||||
        }
 | 
			
		||||
        else { node.warn("No Email credentials found. See info panel."); }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    if (imap) {
 | 
			
		||||
        imap.on('error', function(err) {
 | 
			
		||||
            util.log(err);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this.on("error", function(err) {
 | 
			
		||||
        node.log("error: ",err);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    this.on("close", function() {
 | 
			
		||||
        if (this.interval_id != null) {
 | 
			
		||||
            clearInterval(this.interval_id);
 | 
			
		||||
        }
 | 
			
		||||
        if (imap) { imap.destroy(); }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    node.emit("input",{});
 | 
			
		||||
}
 | 
			
		||||
RED.nodes.registerType("imap",ImapNode);
 | 
			
		||||
@@ -1,53 +0,0 @@
 | 
			
		||||
<!--
 | 
			
		||||
  Copyright 2013 IBM Corp.
 | 
			
		||||
 | 
			
		||||
  Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
  you may not use this file except in compliance with the License.
 | 
			
		||||
  You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
  http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
  Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
  distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
  See the License for the specific language governing permissions and
 | 
			
		||||
  limitations under the License.
 | 
			
		||||
-->
 | 
			
		||||
 | 
			
		||||
<script type="text/x-red" data-template-name="xml2js">
 | 
			
		||||
    <!-- <div class="form-row">
 | 
			
		||||
        <label>Use Console</label>
 | 
			
		||||
        <input type="checkbox" id="node-input-useEyes" placeholder="Name" style="display: inline-block; width: auto; vertical-align: top;">
 | 
			
		||||
        <label for="node-input-useEyes" style="width: 70%;">Debug output in console ?</label>
 | 
			
		||||
    </div> -->
 | 
			
		||||
    <div class="form-row">
 | 
			
		||||
        <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
 | 
			
		||||
        <input type="text" id="node-input-name" placeholder="Name">
 | 
			
		||||
    </div>
 | 
			
		||||
    <!-- <div class="form-tips">Uses xml2js to process xml into javascript object.</div> -->
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<script type="text/x-red" data-help-name="xml2js">
 | 
			
		||||
    <p>A function that parses the <b>msg.payload</b> using the xml2js library. Places the result in the payload.</p>
 | 
			
		||||
    <p>See <a href="https://github.com/Leonidas-from-XIV/node-xml2js/blob/master/README.md" target="_new">the xml2js docs <i>here</i></a> for more information.</p>
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript">
 | 
			
		||||
    RED.nodes.registerType('xml2js',{
 | 
			
		||||
        category: 'deprecated',
 | 
			
		||||
        color:"#E6E0F8",
 | 
			
		||||
        defaults: {
 | 
			
		||||
        //useEyes: {value:false},
 | 
			
		||||
        name: {value:""}
 | 
			
		||||
        },
 | 
			
		||||
        inputs:1,
 | 
			
		||||
        outputs:1,
 | 
			
		||||
        icon: "arrow-in.png",
 | 
			
		||||
        label: function() {
 | 
			
		||||
            return this.name||"xml2json";
 | 
			
		||||
        },
 | 
			
		||||
        labelStyle: function() {
 | 
			
		||||
            return this.name?"node_label_italic":"";
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
</script>
 | 
			
		||||
@@ -1,47 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright 2013 IBM Corp.
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 **/
 | 
			
		||||
 | 
			
		||||
module.exports = function(RED) {
 | 
			
		||||
    "use strict";
 | 
			
		||||
    var util = require("util");
 | 
			
		||||
    var parseString = require('xml2js').parseString;
 | 
			
		||||
    var useColors = true;
 | 
			
		||||
    //util.inspect.styles.boolean = "red";
 | 
			
		||||
 | 
			
		||||
    function Xml2jsNode(n) {
 | 
			
		||||
        RED.nodes.createNode(this,n);
 | 
			
		||||
        this.warn("This node has been deprecated and will be deleted in a future release. Please update your flow to use the 'xml' node.");
 | 
			
		||||
        this.useEyes = n.useEyes||false;
 | 
			
		||||
        var node = this;
 | 
			
		||||
        this.on("input", function(msg) {
 | 
			
		||||
            try {
 | 
			
		||||
                parseString(msg.payload, {strict:true,async:true}, function (err, result) {
 | 
			
		||||
                //parseString(msg.payload, {strict:false,async:true}, function (err, result) {
 | 
			
		||||
                    if (err) { node.error(err); }
 | 
			
		||||
                    else {
 | 
			
		||||
                        msg.payload = result;
 | 
			
		||||
                        node.send(msg);
 | 
			
		||||
                        if (node.useEyes == true) {
 | 
			
		||||
                            node.log("\n"+util.inspect(msg, {colors:useColors, depth:10}));
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
            catch(e) { util.log("[73-parsexml.js] "+e); }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    RED.nodes.registerType("xml2js",Xml2jsNode);
 | 
			
		||||
}
 | 
			
		||||
@@ -1,51 +0,0 @@
 | 
			
		||||
<!--
 | 
			
		||||
  Copyright 2013 IBM Corp.
 | 
			
		||||
 | 
			
		||||
  Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
  you may not use this file except in compliance with the License.
 | 
			
		||||
  You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
  http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
  Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
  distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
  See the License for the specific language governing permissions and
 | 
			
		||||
  limitations under the License.
 | 
			
		||||
-->
 | 
			
		||||
 | 
			
		||||
<script type="text/x-red" data-template-name="json2xml">
 | 
			
		||||
    <div class="form-row">
 | 
			
		||||
        <label for="node-input-name"><i class="fa fa-list"></i> XML Root</label>
 | 
			
		||||
        <input type="text" id="node-input-root" placeholder="object"></input>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="form-row">
 | 
			
		||||
        <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
 | 
			
		||||
        <input type="text" id="node-input-name" placeholder="Name"></input>
 | 
			
		||||
    </div>
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<script type="text/x-red" data-help-name="json2xml">
 | 
			
		||||
    <p>A function that parses the <b>msg.payload</b> using the js2xmlparser library. Places the result back in <b>msg.payload</b>.</p>
 | 
			
		||||
    <p>See the <a href="https://github.com/michaelkourlas/node-js2xmlparser" target="_new">js2xmlparser docs</a> for more information.</p>
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript">
 | 
			
		||||
    RED.nodes.registerType('json2xml',{
 | 
			
		||||
        category: 'deprecated',
 | 
			
		||||
        color:"#E6E0F8",
 | 
			
		||||
        defaults: {
 | 
			
		||||
            name: {value:""},
 | 
			
		||||
            root: {value:"object"},
 | 
			
		||||
        },
 | 
			
		||||
        inputs:1,
 | 
			
		||||
        outputs:1,
 | 
			
		||||
        icon: "arrow-in.png",
 | 
			
		||||
        label: function() {
 | 
			
		||||
            return this.name||"json2xml";
 | 
			
		||||
        },
 | 
			
		||||
        labelStyle: function() {
 | 
			
		||||
            return this.name?"node_label_italic":"";
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
</script>
 | 
			
		||||
@@ -1,39 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright 2013 IBM Corp.
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 **/
 | 
			
		||||
 | 
			
		||||
module.exports = function(RED) {
 | 
			
		||||
    "use strict";
 | 
			
		||||
    var js2xmlparser = require("js2xmlparser");
 | 
			
		||||
 | 
			
		||||
    function Js2XmlNode(n) {
 | 
			
		||||
        RED.nodes.createNode(this,n);
 | 
			
		||||
        this.warn("This node has been deprecated and will be deleted in a future release. Please update your flow to use the 'xml' node.");
 | 
			
		||||
        this.root = n.root;
 | 
			
		||||
        var node = this;
 | 
			
		||||
 | 
			
		||||
        this.on("input", function(msg) {
 | 
			
		||||
            try {
 | 
			
		||||
                var root = node.root || typeof msg.payload;
 | 
			
		||||
                if (typeof msg.payload !== "object") { msg.payload = '"'+msg.payload+'"'; }
 | 
			
		||||
                console.log(root, typeof msg.payload,msg.payload);
 | 
			
		||||
                msg.payload = js2xmlparser(root, msg.payload);
 | 
			
		||||
                node.send(msg);
 | 
			
		||||
            }
 | 
			
		||||
            catch(e) { console.log(e); }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    RED.nodes.registerType("json2xml",Js2XmlNode);
 | 
			
		||||
}
 | 
			
		||||
@@ -1,61 +0,0 @@
 | 
			
		||||
<!--
 | 
			
		||||
  Copyright 2013 IBM Corp.
 | 
			
		||||
 | 
			
		||||
  Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
  you may not use this file except in compliance with the License.
 | 
			
		||||
  You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
  http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
  Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
  distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
  See the License for the specific language governing permissions and
 | 
			
		||||
  limitations under the License.
 | 
			
		||||
-->
 | 
			
		||||
 | 
			
		||||
<script type="text/x-red" data-template-name="httpget">
 | 
			
		||||
    <div class="form-tips"><b>Deprecated</b>: please use the <i>http request</i> node.</div>
 | 
			
		||||
    <br>
 | 
			
		||||
    <div class="form-row">
 | 
			
		||||
        <label for="node-input-baseurl"><i class="fa fa-tasks"></i> Base URL</label>
 | 
			
		||||
        <input type="text" id="node-input-baseurl" placeholder="http(s)://url">
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="form-row">
 | 
			
		||||
        <label for="node-input-append"><i class="fa fa-tasks"></i> Append</label>
 | 
			
		||||
        <input type="text" id="node-input-append" placeholder="">
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="form-row">
 | 
			
		||||
        <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
 | 
			
		||||
        <input type="text" id="node-input-name" placeholder="Name">
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="form-tips">The <b>Base URL</b> gets prepended to whatever payload is passed in. Leave blank if you pass in a full url.<br/>The append gets added to the end after any payload.<br/>The output Topic is the same as the input Topic.</div>
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<script type="text/x-red" data-help-name="httpget">
 | 
			
		||||
	<p>Performs an HTTP or HTTPS GET and returns the fetched page.</p>
 | 
			
		||||
	<p>The return code is placed in <b>msg.rc</b>, and the full text of the result is in <b>msg.payload</b>.</p>
 | 
			
		||||
	<p>The <b>msg.payload</b> is added to the base url, and then the optional append is added after.</p>
 | 
			
		||||
	<p>This is mostly suitable for small pages as large results will need a lot of parsing....</p>
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<script type="text/javascript">
 | 
			
		||||
    RED.nodes.registerType('httpget',{
 | 
			
		||||
        category: 'deprecated',
 | 
			
		||||
        color:"rgb(231, 231, 174)",
 | 
			
		||||
        defaults: {
 | 
			
		||||
            name: {value:""},
 | 
			
		||||
            baseurl: {value:""},
 | 
			
		||||
            append: {value:""}
 | 
			
		||||
        },
 | 
			
		||||
        inputs:1,
 | 
			
		||||
        outputs:1,
 | 
			
		||||
        icon: "white-globe.png",
 | 
			
		||||
        label: function() {
 | 
			
		||||
            return this.name||this.baseurl;
 | 
			
		||||
        },
 | 
			
		||||
        labelStyle: function() {
 | 
			
		||||
            return this.name?"node_label_italic":"";
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
</script>
 | 
			
		||||
@@ -1,53 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright 2013 IBM Corp.
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 **/
 | 
			
		||||
 | 
			
		||||
var RED = require(process.env.NODE_RED_HOME+"/red/red");
 | 
			
		||||
 | 
			
		||||
function HttpGet(n) {
 | 
			
		||||
    RED.nodes.createNode(this,n);
 | 
			
		||||
    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.");
 | 
			
		||||
    this.baseurl = n.baseurl || "";
 | 
			
		||||
    this.append = n.append || "";
 | 
			
		||||
    var node = this;
 | 
			
		||||
    if (this.baseurl.substring(0,5) === "https") { var http = require("https"); }
 | 
			
		||||
    else { var http = require("http"); }
 | 
			
		||||
    this.on("input", function(msg) {
 | 
			
		||||
        msg._payload = msg.payload;
 | 
			
		||||
        //util.log("[httpget] "+this.baseurl+msg.payload+this.append);
 | 
			
		||||
        http.get(this.baseurl+msg.payload+this.append, function(res) {
 | 
			
		||||
            node.log("Http response: " + res.statusCode);
 | 
			
		||||
            msg.rc = res.statusCode;
 | 
			
		||||
            msg.payload = "";
 | 
			
		||||
            if ((msg.rc != 200) && (msg.rc != 404)) {
 | 
			
		||||
                node.send(msg);
 | 
			
		||||
            }
 | 
			
		||||
            res.setEncoding('utf8');
 | 
			
		||||
            res.on('data', function(chunk) {
 | 
			
		||||
                msg.payload += chunk;
 | 
			
		||||
            });
 | 
			
		||||
            res.on('end', function() {
 | 
			
		||||
                node.send(msg);
 | 
			
		||||
            });
 | 
			
		||||
        }).on('error', function(e) {
 | 
			
		||||
            //node.error(e);
 | 
			
		||||
            msg.rc = 503;
 | 
			
		||||
            msg.payload = e;
 | 
			
		||||
            node.send(msg);
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RED.nodes.registerType("httpget",HttpGet);
 | 
			
		||||
		Reference in New Issue
	
	Block a user