readme cleanup
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kenneth Reitz · committed by Kenneth Reitz · parent 47a36de · Browse files · 1 file·+27 added−77 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+27 added−77 removed
- other:+27 added−77 removed
Provenance
- Commit
0b34812- Tree
b09fd0c- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
47a36de
1 file changed+27 added−77 removed
modified:README.rst+27 added-77 removed
1 Requests: HTTP for Humans2 =========================3 4-Most existing Python modules for dealing HTTP requests are insane. I have to look up *everything* that I want to do. Most of my worst Python experiences are a result of the various built-in HTTP libraries (yes, even worse than Logging).4+Requests is an ISC Licensed HTTP library, written in Python, for human5+beings.6 6-But this one's different. This one's going to be awesome. And simple.7+Most existing Python modules for sending HTTP requests are extremely8+verbose and cumbersome. Python’s builtin urllib2 module provides most of9+the HTTP capabilities you should need, but the api is thoroughly broken.10+It requires an enormous amount of work (even method overrides) to11+perform the simplest of tasks.12 8-Really simple.13+Things shouldn’t be this way. Not in Python.14 15+::16+17+ >>> r = requests.get('https://api.github.com', auth=('user', 'pass'))18+ >>> r.status_code19+ 20420+ >>> r.headers['content-type']21+ 'application/json'22+ >>> r.content23+ ...24+25+See `the same code, without Requests <https://gist.github.com/973705>`_.26+27+Requests allow you to send **HEAD**, **GET**, **POST**, **PUT**,28+**PATCH**, and **DELETE** HTTP requests. You can add headers, form data,29+multipart files, and parameters with simple Python dictionaries, and access the30+response data in the same way. It's powered by :py:class:`urllib2`, but it does31+all the hard work and crazy hacks for you.32+33+34 Features35 --------36 37 - Extremely simple HEAD, GET, POST, PUT, PATCH, DELETE Requests40 unmodified lines78 >>> r.content79 '{"authenticated": true, "user": "user"}'80 81 58-59-API60----61-62-**Requests:**63-64-All request functions return a Response object (see below).65-66-If a {filename: fileobject} dictionary is passed in (files=...), a multipart_encode upload will be performed.67-If CookieJar object is is passed in (cookies=...), the cookies will be sent with the request.68-69- HEAD Requests70- >>> requests.head(url, params={}, headers={}, cookies=None, auth=None, timeout=None, proxies={})71- <Response [200]>72-73- GET Requests74- >>> requests.get(url, params={}, headers={}, cookies=None, auth=None, timeout=None, proxies={})75- <Response [200]>76-77- POST Requests78- >>> requests.post(url, data={}, headers={}, files={}, cookies=None, auth=None, timeout=None, allow_redirects=False, params{}, proxies={})79- <Response [200]>80-81- PUT Requests82- >>> requests.put(url, data={}, headers={}, files={}, cookies=None, auth=None, timeout=None, allow_redirects=False, params{}, proxies={})83- <Response [200]>84-85- PATCH Requests86- >>> requests.patch(url, data={}, headers={}, files={}, cookies=None, auth=None, timeout=None, allow_redirects=False, params{}, proxies={})87- <Response [200]>88-89- DELETE Requests90- >>> requests.delete(url, params={}, headers={}, cookies=None, auth=None, timeout=None, allow_redirects=False, params{}, proxies={})91- <Response [200]>92-93-94-**Responses:**95-96- Response.status_code97- (Integer) Received HTTP Status Code Response98-99- Response.headers100- ((CaseInsensitive) Dictionary) Received HTTP Response Headers.101-102- Response.content103- (Bytes) Received Content.104-105- Response.history106- (List of Responses) Redirection History.107-108- Response.url109- (String) URL of response. Useful for detecting redirects.110-111- Response.ok112- (Bool) True if no errors occurred during the request, and the status_code is kosher.113-114- Response.cached115- (Bool) True if Response.content is stored within the object.116-117- Response.error118- (HTTPError) If an HTTPError occurred (e.g. status of 404), Otherwise this is None.119-120- Response.raise_for_status()121- Raises HTTPError if a request is not kosher.122-123-124-**HTTP Authentication Registry:**125-126- You can register AuthObjects to automatically enable HTTP Authentication on requests that contain a registered base URL string.127-128- >>> requests.auth_manager.add_auth(url, authobject)129-130-131-82 Installation83 ------------84 85 To install requests, simply: ::25 unmodified lines