8000 fix: Respect HTTPS_PROXY and other settings from env vars by AlanCoding · Pull Request #592 · twilio/twilio-python · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@AlanCoding
Copy link
Contributor

Fixes

Feature addition.

This is a followup from #409, where this goes further to allow setting proxy servers using the typical environment variables, as opposed to passing them in via the python interface.

See the docs here:

https://docs.python-requests.org/en/master/user/advanced/

When you are using the prepared request flow, keep in mind that it does not take into account the environment. This can cause problems if you are using environment variables to change the behaviour of requests. For example: Self-signed SSL certificates specified in REQUESTS_CA_BUNDLE will not be taken into account. As a result an SSL: CERTIFICATE_VERIFY_FAILED is thrown. You can get around this behaviour by explicitly merging the environment settings into your session:

I would like for this library to respect all of these settings without extra work on the python interface to it. This appears to be the canonical way to work this into the requests library usage happening here.

This unfortunately increase the amount of mocking required, as the new call to merge_environment_settings will do a URL split on the request's URL. This means that the request object needs to be more complex than Mock().

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 main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the 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.

@sugitk
Copy link
sugitk commented Apr 17, 2022

Hi Admins in this project,

How can we get reviewers and approvals in this PR? Our customer is still waiting for the fix.
Thank you in advance.

@AlanCoding
Copy link
Contributor Author

I rebased this PR, last time I wasn't able to open the output of some of the checks (DeepSource). Maybe I'll have more luck this time.

@AlanCoding AlanCoding changed the title Respect HTTPS_PROXY and other settings from env vars fix: Respect HTTPS_PROXY and other settings from env vars May 9, 2022
@AlanCoding
Copy link
Contributor Author

I put the "fix:" on title and commit, maybe that helps.

Copy link
Contributor
@childish-sambino childish-sambino left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

3 participants

0