Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated HTTP Request Node to use proxies and added a couple of options #2353

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 50 additions & 3 deletions packages/nodes-base/nodes/HttpRequest.node.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { request } from 'http';
import {
BINARY_ENCODING,
IExecuteFunctions,
Expand Down Expand Up @@ -351,9 +352,34 @@ export class HttpRequest implements INodeType {
name: 'proxy',
type: 'string',
default: '',
placeholder: 'http://myproxy:3128',
placeholder: 'myproxy:3128',
description: 'HTTP proxy to use.',
},
{
displayName: 'Proxy Type',
name: 'proxyType',
type: 'options',
options: [
{
name: 'HTTP',
value: 'http',
},
{
name: 'HTTPS',
value: 'https',
},
],
default: 'https',
description: '',
},
{
displayName: 'Proxy Credentials',
name: 'proxyCredentials',
type: 'string',
default: '',
placeholder: 'user:password',
description: 'Credentials for the proxy',
},
{
displayName: 'Split Into Items',
name: 'splitIntoItems',
Expand Down Expand Up @@ -712,7 +738,28 @@ export class HttpRequest implements INodeType {
requestOptions.simple = false;
}
if (options.proxy !== undefined) {
requestOptions.proxy = options.proxy as string;
const proxyOptions = {};
let proxy = (options.proxy as string).split(":");
// @ts-ignore
proxyOptions.host = proxy[0];
// @ts-ignore
proxyOptions.port = parseInt(proxy[1]);

if (options.proxyType !== undefined) {
// @ts-ignore
proxyOptions.protocol = options.proxyType as string;
}

if (options.proxyCredentials !== undefined) {
// @ts-ignore
proxyOptions.auth = {};
let credentials = (options.proxyCredentials as string).split(":");
// @ts-ignore
proxyOptions.auth.username = credentials[0];
// @ts-ignore
proxyOptions.auth.password = credentials[1];
}
requestOptions.proxy = proxyOptions;
}
if (options.timeout !== undefined) {
requestOptions.timeout = options.timeout as number;
Expand Down Expand Up @@ -1057,4 +1104,4 @@ export class HttpRequest implements INodeType {

return this.prepareOutputData(returnItems);
}
}
}