-
Notifications
You must be signed in to change notification settings - Fork 513
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
Conversation
Hey @childish-sambino is there anything else required for this? |
It's on my list of items to review. |
@@ -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'; |
There was a problem hiding this comment.
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';
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just suggesting a less-verbose replacement that's functionally equivalent.
@@ -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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just suggesting a less-verbose replacement that's functionally equivalent.
Hi. Just checking in if this can be merged yet? |
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
If you have questions, please file a support ticket, or create a GitHub Issue in this repository.