Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, I have spent the past 15 years working in professional environments where the http/https proxy was the most annoying issue to myself and all my developer colleagues (in java, matlab, python...). A few years ago I even ended up writing a internal tutorial for our corporate proxy, a public one (https://smarie.github.io/develop-behind-proxy/), and a environment switching tool (https://smarie.github.io/env-switcher-gui/) that is used by many of us especially the ones switching from home office to work place regularly.
This introduction just to say that even if this is issue is now fairly trivial to me, I have been helping hundreds of colleagues over the year (and am still from time to time) so I believe that it is not yet easy to understand for most people.
requests
is working perfectly fine with proxies. However the way it finds the proxy-related information is not very well documented, and the way one can override this information on aSession
is quite un-pythonic (a plain dict, therefore possibly error-prone). Some work I did a few months ago usingrequests-oauthlib
made me once again think that it would be extremely helpful to have a good helper function on theSession
object.This PR contains two things:
Session.set_http_proxy
method with associated unit testsI had one afterthought after completing this, maybe you'll find this relevant too: instead of providing just one
set_http_proxy
method, maybe it would be better to split it into two :set_http_proxy
andset_https_proxy
. Far more simple and elegant in my opinion, but I'll wait for your first feedback before modding anything here.Thanks for your time and for maintaining this great lib!