Requests is an ISC Licensed HTTP library, written in Python, for human beings.<p>Requests allow you to send HEAD, GET, POST, PUT, PATCH, and DELETE HTTP requests. You can add headers, form data, multipart files, and parameters with simple Python dictionaries, and access the response data in the same way. It’s powered by urllib2, but it does all the hard work and crazy hacks for you.
Absolutely my favourite recent development in the Python world. I won't be mistaken if I say that many of us have built half-arse versions of this on top of urllib(2) multiple times in the past. :-)<p>The support for keep-alive is particularly welcome, huge kudos to the author.<p>Question to users of other languages: do equivalents exist for PHP, Perl, C# or Java? Ruby folks rave about restclient, but is there anything else?
Discussion from the two month old submission: <a href="http://news.ycombinator.com/item?id=2882301" rel="nofollow">http://news.ycombinator.com/item?id=2882301</a>
This looks so nice. Is there any upcoming support for HTTP caching? I know it is not the easiest thing to do because you will probably need to make several cache backends (file, db, memcached, redis, etc.) to keep everyone happy.<p>Also I couldn't tell if there is keep-alive support, is there?
I don't mean to badmouth Requests or Python in general, it certainly looks like an improvement, but can anyone enlighten me as to why an API that wraps an HTTP request with concise methods is #1 on HN, twice? This looks more like a good answer to SO question than "news".<p>This looks like all the other wrapper methods you spend 5 minutes doing, once, when you start a new codebase?
Link to previous discussion on HN:<p><a href="http://news.ycombinator.com/item?id=2882301" rel="nofollow">http://news.ycombinator.com/item?id=2882301</a>
Forgive me if I've missed this, but does this library have support for multipart/form-data POSTing? That's a capability in the python library that's sorely missing - especially in 2.X.
Although Requests looks very nice, I've wondered why most people wouldn't simply use pycurl - <a href="http://pycurl.sourceforge.net/" rel="nofollow">http://pycurl.sourceforge.net/</a> ? It's stable and you get all the power that cURL has (which is a lot), and the API is fairly simple - although maybe not as pythonic as the Requests API is.<p>On a side note: last time I checked urllib2 (which actually drives Requests) could not do SSL requests over a proxy, which gave me the feeling that this implementation still isn't very mature.
I love Requests, but it would be really nice to have some Python libraries with cert-verified SSL support. I've hacked SSL support on top of urllib2 for my projects at work (<a href="https://github.com/josephturnerjr/urllib2.VerifiedHTTPS" rel="nofollow">https://github.com/josephturnerjr/urllib2.VerifiedHTTPS</a>), but it'd be really nice if libraries started prioritizing secure communications as a first-order requirement.
I note that you call gevent.monkey.patch_all() in async.<p>I'm still fairly new to gevent and I'm curious if others consider this good style for a library?
Trying to use the requests module yields:<p><pre><code> File "/usr/lib/python2.6/cookielib.py", line 38, in <module>
from calendar import timegm</code></pre>
ImportError: cannot import name timegm<p>for me.<p>On two different machines, one OSX SL with Python 2.6 from MacPorts and the other Ubuntu 10.04.3 LTS with Python 2.6 via aptitude.<p>Can not find any solution for this via Google and its siblings.<p>I'm stuck :(<p>-jsl
Excellent library but they need to fix this piece of misinformation: "A project that is released as GPL cannot be used in any commercial product without the product itself also being offered as open source."<p>This is false. A project released as GPL can also be released on another (commercial) license.
If Python is going to include urllib or urllib2 in the standard distro, why not make it good? Http is foundational to (web) programming. I am shocked at how poor the standard httpclient implementations are in most environments.
Oh, what I would give for a "mechanize for humans" built on this! I love mechanize, but I dream of not having to go back to its one page documentation and the source code every time I want to do something.
There is also an addon for Requests that lets you make OAuth requests: <a href="https://github.com/maraujop/requests-oauth-hook" rel="nofollow">https://github.com/maraujop/requests-oauth-hook</a>
How does this compare (feature wise) to the poster library? Are they about the same? I've used poster some, but not requests... I'll have to try it now. Just curious how it compares to poster.
Given that there are a great deal of service APIs in the wild this is going to lower the barrier of entry for many less experienced developers looking to prototype their ideas.