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

fix: updated RequestClient to handle proxy from default PROXY_HOST env var #590

Merged
merged 6 commits into from
Feb 8, 2021

Conversation

tlawrie
Copy link
Contributor

@tlawrie tlawrie commented Jul 1, 2020

Fixes #336

Description:
This fix updates the RequestClient to look at the default PROXY_HOST environment variable. It retains all original options however moves the keep-alive into the Connection header. Removes the http.Agent and https.Agent and replaces with the https-proxy-agent extension to handle the proxy variable. Additionally as mentioned in the Axios issues set the proxy to false (Axios issue reference: axios/axios#2072).

This has been tested in a simple node request. End users do not have to provide any additional information when calling Twilio for a client and as such has no breaking change.

Test Code:
Taken from https://www.twilio.com/docs/sms/tutorials/how-to-send-sms-messages-node-js?code-sample=code-send-an-sms-using-the-programmable-sms-api&code-language=Node.js&code-sdk-version=3.x

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the master branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

If you have questions, please file a support ticket, or create a GitHub Issue in this repository.

@tlawrie
Copy link
Contributor Author

tlawrie commented Jul 2, 2020

Hey @childish-sambino is there anything else required for this?

@childish-sambino
Copy link
Contributor

It's on my list of items to review.

@thinkingserious thinkingserious changed the base branch from master to main July 28, 2020 14:40
@childish-sambino childish-sambino changed the title fix: updated RequestClient to handle proxy from default PROXY_HOST en… fix: updated RequestClient to handle proxy from default PROXY_HOST env var Aug 6, 2020
@@ -41,7 +40,9 @@ RequestClient.prototype.request = function(opts) {
var deferred = Q.defer();
var headers = opts.headers || {};

if (!headers.Connection && !headers.connection) {
if (!headers.Connection && !headers.connection && opts.forever) {
headers.Connection = 'keep-alive';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: headers.Connection = opts.forever ? 'keep-alive' : 'close';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi. Apologies. Not following. NIT?

I think you are suggesting there is an alternate better approach here?

Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Just suggesting a less-verbose replacement that's functionally equivalent.

lib/base/RequestClient.js Show resolved Hide resolved
@@ -41,7 +40,9 @@ RequestClient.prototype.request = function(opts) {
var deferred = Q.defer();
var headers = opts.headers || {};

if (!headers.Connection && !headers.connection) {
if (!headers.Connection && !headers.connection && opts.forever) {
headers.Connection = 'keep-alive';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Just suggesting a less-verbose replacement that's functionally equivalent.

@tlawrie
Copy link
Contributor Author

tlawrie commented Jan 29, 2021

Hi. Just checking in if this can be merged yet?

@tlawrie
Copy link
Contributor Author

tlawrie commented Feb 15, 2021

@thinkingserious 👍

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.

Feature Request: Add way to specify proxy for requests
3 participants