Skip to content

Conversation

@jc21
Copy link

@jc21 jc21 commented Jan 2, 2018

Fixes #75

Tested on environments both with and without a proxy environment variable suitably defined.

Thanks to @rayterrill for the initial work on this.

@jc21 jc21 changed the title #75 - Added HTTP Proxy Support Added HTTP Proxy Support Jan 2, 2018
index.js Outdated

console.assert(params.token, 'token must be defined');

// Use a HTTP Proxy if defined in the environment. We need to accomodate both uppercase and lowercase environment definitions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as sugestion, this could be refactored into an encapsulated proxy setup method or similar :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. As a bonus, defining a proxy param in the constructor will be respected before looking at the environment.

index.js Outdated
// Use a HTTP Proxy if defined in the environment. We need to accomodate both uppercase and lowercase environment definitions
this._agent = null;
if ((typeof process.env.http_proxy !== 'undefined' && process.env.http_proxy) || (typeof process.env.HTTP_PROXY !== 'undefined' && process.env.HTTP_PROXY)) {
this._agent = new HttpsProxyAgent(Url.parse(process.env.http_proxy || process.env.HTTP_PROXY));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen if Url.parse return error?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have updated to code handle any throws from Url.parse and to check if the parse didn't fail but didn't succeed either :/

@rayterrill
Copy link

First Github pull request ever @jc21! :)

@jc21
Copy link
Author

jc21 commented Jan 9, 2018

That latest CI failure is compilation related, timed out trying to install nvm. Can you re-trigger?

@bullidium
Copy link

Is there any progress with this PR as this is to something that I'd be keen to utilise as well?

@heyitsols
Copy link

@jesuslg123 is there any movement on this being merged into the project please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants