diff --git a/nodes/core/io/21-httpin.html b/nodes/core/io/21-httpin.html
index a8c653c28..d8dff0ead 100644
--- a/nodes/core/io/21-httpin.html
+++ b/nodes/core/io/21-httpin.html
@@ -121,8 +121,9 @@
The URL and HTTP method can be configured in the node, but also
overridden by the incoming message:
- url
, if set, is used as the url of the request
- method
, if set, is used as the HTTP method of the request. Must be one of GET
, PUT
, POST
or DELETE
(default: GET)
+ url
, if set, is used as the url of the request. Must start with http: or https:
+ method
, if set, is used as the HTTP method of the request.
+ Must be one of GET
, PUT
, POST
or DELETE
(default: GET)
headers
, if set, should be an object containing field/value
pairs to be added as request headers
payload
is sent as the body of the request
diff --git a/nodes/core/io/21-httpin.js b/nodes/core/io/21-httpin.js
index bbc8b411c..fbe7f7aae 100644
--- a/nodes/core/io/21-httpin.js
+++ b/nodes/core/io/21-httpin.js
@@ -16,7 +16,6 @@
module.exports = function(RED) {
"use strict";
- var util = require("util");
var http = require("follow-redirects").http;
var https = require("follow-redirects").https;
var urllib = require("url");
@@ -159,6 +158,11 @@ module.exports = function(RED) {
} else {
url = nodeUrl;
}
+ // url must start http:// or https:// so assume http:// if not set
+ if (!((url.indexOf("http://")===0) || (url.indexOf("https://")===0))) {
+ url = "http://"+url;
+ }
+
var method = (msg.method||nodeMethod).toUpperCase();
//node.log(method+" : "+url);
var opts = urllib.parse(url);
@@ -208,7 +212,7 @@ module.exports = function(RED) {
});
});
req.on('error',function(err) {
- msg.payload = err.toString();
+ msg.payload = err.toString() + " : " + url;
msg.statusCode = err.code;
node.send(msg);
node.status({fill:"red",shape:"ring",text:err.code});
@@ -219,7 +223,7 @@ module.exports = function(RED) {
req.end();
});
}
-
+
RED.nodes.registerType("http request",HTTPRequest,{
credentials: {
user: {type:"text"},