Skip to content
Myr

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

1 file+27 added−77 removed

modified:README.rst+27 added-77 removed
1Requests: HTTP for Humans2=========================34Most 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).4Requests is an ISC Licensed HTTP library, written in Python, for human5beings.66But this one's different. This one's going to be awesome. And simple.7Most existing Python modules for sending HTTP requests are extremely8verbose and cumbersome. Python’s builtin urllib2 module provides most of9the HTTP capabilities you should need, but the api is thoroughly broken.10It requires an enormous amount of work (even method overrides) to11perform the simplest of tasks.128Really simple.13Things shouldn’t be this way. Not in Python.1415::1617 >>> 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 ...2425See `the same code, without Requests <https://gist.github.com/973705>`_.2627Requests allow you to send **HEAD**, **GET**, **POST**, **PUT**,28**PATCH**, and **DELETE** HTTP requests. You can add headers, form data,29multipart files, and parameters with simple Python dictionaries, and access the30response data in the same way. It's powered by :py:class:`urllib2`, but it does31all the hard work and crazy hacks for you.323334Features35--------3637- Extremely simple HEAD, GET, POST, PUT, PATCH, DELETE Requests
40 unmodified lines
78 >>> r.content79 '{"authenticated": true, "user": "user"}'80815859API60---6162**Requests:**6364All request functions return a Response object (see below).6566If a {filename: fileobject} dictionary is passed in (files=...), a multipart_encode upload will be performed.67If CookieJar object is is passed in (cookies=...), the cookies will be sent with the request.6869 HEAD Requests70 >>> requests.head(url, params={}, headers={}, cookies=None, auth=None, timeout=None, proxies={})71 <Response [200]>7273 GET Requests74 >>> requests.get(url, params={}, headers={}, cookies=None, auth=None, timeout=None, proxies={})75 <Response [200]>7677 POST Requests78 >>> requests.post(url, data={}, headers={}, files={}, cookies=None, auth=None, timeout=None, allow_redirects=False, params{}, proxies={})79 <Response [200]>8081 PUT Requests82 >>> requests.put(url, data={}, headers={}, files={}, cookies=None, auth=None, timeout=None, allow_redirects=False, params{}, proxies={})83 <Response [200]>8485 PATCH Requests86 >>> requests.patch(url, data={}, headers={}, files={}, cookies=None, auth=None, timeout=None, allow_redirects=False, params{}, proxies={})87 <Response [200]>8889 DELETE Requests90 >>> requests.delete(url, params={}, headers={}, cookies=None, auth=None, timeout=None, allow_redirects=False, params{}, proxies={})91 <Response [200]>929394**Responses:**9596 Response.status_code97 (Integer) Received HTTP Status Code Response9899 Response.headers100 ((CaseInsensitive) Dictionary) Received HTTP Response Headers.101102 Response.content103 (Bytes) Received Content.104105 Response.history106 (List of Responses) Redirection History.107108 Response.url109 (String) URL of response. Useful for detecting redirects.110111 Response.ok112 (Bool) True if no errors occurred during the request, and the status_code is kosher.113114 Response.cached115 (Bool) True if Response.content is stored within the object.116117 Response.error118 (HTTPError) If an HTTPError occurred (e.g. status of 404), Otherwise this is None.119120 Response.raise_for_status()121 Raises HTTPError if a request is not kosher.122123124**HTTP Authentication Registry:**125126 You can register AuthObjects to automatically enable HTTP Authentication on requests that contain a registered base URL string.127128 >>> requests.auth_manager.add_auth(url, authobject)12913013182Installation83------------8485To install requests, simply: ::
25 unmodified lines