Comments (12)
Interesting idea!
Are you thinking something along the lines of...
with requests.settings(path='http://example.org', timeout=10) as r:
response = r.get('/path/to/file.txt')
...?
from requests.
Heh, neat path idea.
I was thinking:
with requests.settings(timeout=10, auth=('a', 'b'), proxies={'http': 'localhost:8080'}):
requests.get('http://blah.com/', params={'x': 'y'})
from requests.
either way I think that's awesome.
from requests.
Let's do it :)
from requests.
Maybe this would be better:
with requests.settings(timeout=10, auth=('a', 'b'), proxies={'http': 'localhost:8080'}) as r:
r.get('http://blah.com/')
This would escape the threading/processes issues.
from requests.
If there's a way to detect if someone's using as r
, then I'm all for doing it now. Otherwise, I'm going to think about it for a while.
from requests.
My thought is always that explicit is better than implicit. And intuitiveness goes along with it. So then are context processors more explicit and are they intuitive?
This does look like a divergence from the intuitive aspect of Requests that I like so much. I can point other newbies at it and they just get it. I'm open to ideas, but keep in mind your audience. Use of context processors could be for advanced users, and be given appropriate documentation.
from requests.
Great points.
If I do decide to implement this, it would be supplementary. All of the functions will accept the same paramaters they do now as well.
from requests.
Maybe I'll hold off on this for now.
Currently, you can do the following
>>> with requests.settings(verbose=sys.stderr):
... requests.get('http://httpbin.org/ip')
2011-06-23T21:23:18.422726 GET http://httpbin.org/ip
<Response [200]>
>>> requests.get('http://httpbin.org/ip')
<Response [200]>
As an alternative to:
>>> requests.settings.verbose=sys.stderr
>>> requests.get('http://httpbin.org/ip')
2011-06-23T21:23:18.422726 GET http://httpbin.org/ip
<Response [200]>
>>> requests.settings.verbose=None
>>> requests.get('http://httpbin.org/ip')
<Response [200]>
I love this.
Maybe, it would just be best to move proxies into the settings module instead of being required to be passed into each request function for now.
from requests.
Decided: current settings
singleton use is a non-issue because request.settings
should only manage (supplementarily) all-encompassing settings (timeouts, proxies, etc).
Auth Management still needs to be rethought.
from requests.
See #75 for Re: Proxy
from requests.
I'd also like to move all non-essential keyword arguments (timeout, proxies, cookies) into a well-documented and constient **kwargs
again. This will solve the 'paramaters getting out of hand' issue.
Closed.
from requests.
Related Issues (20)
- Can't access trailers with the Request library HOT 1
- AttributeError: 'NoneType' object has no attribute 'setdefault' on environment proxies HOT 3
- Connection problems HOT 1
- Request not throwing requests.exceptions.InvalidSchema on custom HTTPAdapter HOT 3
- Requests roadmap HOT 5
- 2.32.0 sdist is missing `tests/certs` HOT 4
- Requests 2.32.0 Not supported URL scheme http+docker HOT 16
- breaking aws s3 usage with requests 2.32.0
- Not supported URL scheme http+docker KOLLA ANSIBLE HOT 1
- SSLV3_ALERT_HANDSHAKE_FAILURE after upgrade from 2.31.0 to 2.32.2 HOT 20
- SSLCertVerificationError - unable to get local issuer certificate HOT 5
- ERROR - Cannot set verify_mode to CERT_NONE when check_hostname is enabled HOT 1
- Enhance Error Messaging for Connection Failures
- Different default values for "allow_redirects" for HEAD http method HOT 4
- Multiple concurrent client certs broken with v2.32.3 HOT 4
- ssl certificate validation of requests was ignored but the ssl certificate still reported an error HOT 1
- ssl certificate validation of requests was ignored but the ssl certificate still reported an error HOT 2
- Certificate loading regression with HTTPAdapters in 2.32.3
- Deprecated `HTTPAdapter.get_connection()` method is never called, causing breakage without deprecation warnings HOT 2
- requests 2.32.3 & urllib3 1.26.18 issue with unicode put HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from requests.