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

feat: Add ability to set proxy #75

Merged
merged 1 commit into from
Oct 4, 2018

Conversation

eitoball
Copy link
Contributor

@eitoball eitoball commented Oct 2, 2018

Fixes #70

Checklist

  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the [Contribution Guide] and my PR follows them.
  • I 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 example file
  • I have added in line documentation to the code I modified

Short description of what this PR does:

  • This PR should add ability to set proxy when initializing Sendgrid::Client.

Sample

host = 'https://example.com'
headers = { 'Authorization' => 'Bearer xxx' }
proxy_options = { host: 'localhost', port: 8080, user: 'anonymous', pass: 'secret' }
client = SendGrid::Client.new(host: host, request_headers: headers, proxy_options: proxy_options }
res = client.version('v3').get

@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Oct 2, 2018
@SendGridDX
Copy link

SendGridDX commented Oct 2, 2018

CLA assistant check
All committers have signed the CLA.

@kplimack kplimack self-requested a review October 2, 2018 15:16
# request_headers: headers,
# proxy_options: { host: '127.0.0.1', port: 8080 })
#
# (2) Set 'http_proxy' environment variable
Copy link
Contributor

Choose a reason for hiding this comment

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

what about https_proxy ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, you cannot use https_proxy. It is from ruby's `URI::Generic#find_proxy'.

@kplimack
Copy link
Contributor

kplimack commented Oct 2, 2018

@eitoball I'm not sure that it is a safe idea for the client code to mutate environment variables. If one of those is set the client should respect it. It makes more sense to instantiate the class like you have in example#1 passing the proxy settings explicitly.

@kplimack kplimack self-assigned this Oct 2, 2018
@eitoball
Copy link
Contributor Author

eitoball commented Oct 2, 2018

@kplimack I am not sure what you mean by "mutate environment variables". Example (2) in examples/example.rb is just showing that you can use http_proxy environment variable to set proxy. The environment variable can be set in shell like export http_proxy=127.0.0.1:8080.

@thinkingserious thinkingserious added type: community enhancement feature request not on Twilio's roadmap difficulty: medium fix is medium in difficulty hacktoberfest status: ready for deploy code ready to be released in next deploy and removed status: code review request requesting a community code review or review from Twilio labels Oct 4, 2018
@thinkingserious
Copy link
Contributor

Hello @eitoball,

Thanks again for the PR!

It's HACKTOBERFEST! We want to show our appreciation by sending you some special Hacktoberfest swag. If you have not already, could you please fill out this form so we can send it to you? Thanks!

Team SendGrid DX

@thinkingserious thinkingserious merged commit 5187a42 into sendgrid:master Oct 4, 2018
@thinkingserious
Copy link
Contributor

Hello @eitoball,

Thanks again for the PR!

We noticed that you have earned 3 out of the 5 points needed to receive glorious SendGrid Hacktoberfest swag.

Please take a moment to checkout this link to find more issues to get you past the required threshold.

Also, please be sure that you have officially registered here.

Thank you and Happy Hacktobering!

Team SendGrid DX

@thinkingserious
Copy link
Contributor

Hello @eitoball,

Thanks again for the PR!

You have earned 3 out of the 5 points needed to receive glorious SendGrid Hacktoberfest swag.

Please take a moment to checkout this link to find more issues to get you past the required threshold or to simply continue the celebration.

Also, please be sure you have officially registered with us here by November 1, 2018 to qualify.

If you have any questions you can email us at [email protected].

Thank you and Happy Hacktobering!

Team SendGrid

@thinkingserious thinkingserious changed the title Add ability to set proxy feat: Add ability to set proxy Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium fix is medium in difficulty status: ready for deploy code ready to be released in next deploy type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the ability to set a proxy
4 participants