mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Adds proxy support to http node - via settings.js
This commit is contained in:
parent
0bef04ae0a
commit
17f3366556
@ -152,6 +152,7 @@
|
|||||||
<li><code>statusCode</code> is the status code of the response, or the error code if the request could not be completed</li>
|
<li><code>statusCode</code> is the status code of the response, or the error code if the request could not be completed</li>
|
||||||
<li><code>headers</code> is an object containing the response headers</li>
|
<li><code>headers</code> is an object containing the response headers</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<p><b>Note</b>: See the <i>settings.js</i> file if you need to configure a proxy.</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -199,9 +200,9 @@
|
|||||||
$("#node-input-path").html(root);
|
$("#node-input-path").html(root);
|
||||||
$("#node-input-tip").show();
|
$("#node-input-tip").show();
|
||||||
}
|
}
|
||||||
if(!RED.nodes.getType("swagger-doc")){
|
if(!RED.nodes.getType("swagger-doc")){
|
||||||
$('.row-swagger-doc').hide();
|
$('.row-swagger-doc').hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -192,7 +192,7 @@ module.exports = function(RED) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// url must start http:// or https:// so assume http:// if not set
|
// url must start http:// or https:// so assume http:// if not set
|
||||||
if (!((url.indexOf("http://")===0) || (url.indexOf("https://")===0))) {
|
if (!((url.indexOf("http://") === 0) || (url.indexOf("https://") === 0))) {
|
||||||
url = "http://"+url;
|
url = "http://"+url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +243,18 @@ module.exports = function(RED) {
|
|||||||
opts.headers['content-length'] = Buffer.byteLength(payload);
|
opts.headers['content-length'] = Buffer.byteLength(payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var req = ((/^https/.test(url))?https:http).request(opts,function(res) {
|
var urltotest = url;
|
||||||
|
if (RED.settings.httpNodeProxy) {
|
||||||
|
var proxy = RED.settings.httpNodeProxy.host;
|
||||||
|
opts.protocol = "http:";
|
||||||
|
opts.headers['Host'] = opts.host;
|
||||||
|
opts.host = opts.hostname = proxy;
|
||||||
|
opts.port = RED.settings.httpNodeProxy.port || opts.port;
|
||||||
|
if (opts.port) { opts.host = opts.host+":"+opts.port; }
|
||||||
|
opts.path = opts.pathname = opts.href;
|
||||||
|
urltotest = proxy;
|
||||||
|
}
|
||||||
|
var req = ((/^https/.test(urltotest))?https:http).request(opts,function(res) {
|
||||||
(node.ret === "bin") ? res.setEncoding('binary') : res.setEncoding('utf8');
|
(node.ret === "bin") ? res.setEncoding('binary') : res.setEncoding('utf8');
|
||||||
msg.statusCode = res.statusCode;
|
msg.statusCode = res.statusCode;
|
||||||
msg.headers = res.headers;
|
msg.headers = res.headers;
|
||||||
|
@ -120,7 +120,11 @@ module.exports = {
|
|||||||
// origin: "*",
|
// origin: "*",
|
||||||
// methods: "GET,PUT,POST,DELETE"
|
// methods: "GET,PUT,POST,DELETE"
|
||||||
//},
|
//},
|
||||||
|
|
||||||
|
// The following property can be used to configure a proxy for use by the
|
||||||
|
// http request node.
|
||||||
|
//httpNodeProxy : { host:"myproxy.acme.com", port:8080 },
|
||||||
|
|
||||||
// Anything in this hash is globally available to all functions.
|
// Anything in this hash is globally available to all functions.
|
||||||
// It is accessed as context.global.
|
// It is accessed as context.global.
|
||||||
// eg:
|
// eg:
|
||||||
|
Loading…
Reference in New Issue
Block a user