quickstart.rst
This file
Path
docs/user/quickstart.rst
462 lines · 13.1 KiB
Last changed by
Merge pull request #784 from Locker537/docs_fixKenneth Reitzbefore adoptioncb0fdd8
History of this fileTake it
The walk stopped after 200 commits: lines older than 9427e1e point at it.
missed an importKenneth Reitzbefore adoption9427e1e
lines 1–17why, one step back1.. _quickstart:23Quickstart4==========56.. module:: requests.models78Eager to get started? This page gives a good introduction in how to get started9with Requests. This assumes you already have Requests installed. If you do not,10head over to the :ref:`Installation <install>` section.1112First, make sure that:1314* Requests is :ref:`installed <install>`15* Requests is :ref:`up-to-date <updates>`1617Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 18why, one step back18Let's get started with some simple examples.missed an importKenneth Reitzbefore adoption9427e1e
lines 19–20why, one step back1920Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 21why, one step back21Make a Requestmissed an importKenneth Reitzbefore adoption9427e1e
lines 22–23why, one step back22------------------23Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 24why, one step back24Making a request with Requests is very simple.missed an importKenneth Reitzbefore adoption9427e1e
line 25why, one step back25Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 26why, one step back26Begin by importing the Requests module::Merge pull request #784 from Locker537/docs_fixKenneth Reitzbefore adoptioncb0fdd8
line 27why, one step back27Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 28why, one step back28 >>> import requestsmissed an importKenneth Reitzbefore adoption9427e1e
line 29why, one step back29Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 30–31why, one step back30Now, let's try to get a webpage. For this example, let's get GitHub's public31timeline ::missed an importKenneth Reitzbefore adoption9427e1e
line 32why, one step back32Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 33–34why, one step back33 >>> r = requests.get('https://github.com/timeline.json')34missed an importKenneth Reitzbefore adoption9427e1e
line 35why, one step back35Now, we have a :class:`Response` object called ``r``. We can get all theMerge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 36why, one step back36information we need from this object.missed an importKenneth Reitzbefore adoption9427e1e
line 37why, one step back37Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 38–39why, one step back38Requests' simple API means that all forms of HTTP request are as obvious. For39example, this is how you make an HTTP POST request::Merge pull request #784 from Locker537/docs_fixKenneth Reitzbefore adoptioncb0fdd8
line 40why, one step back40Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 41why, one step back41 >>> r = requests.post("http://httpbin.org/post")missed an importKenneth Reitzbefore adoption9427e1e
line 42why, one step back42Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 43–44why, one step back43Nice, right? What about the other HTTP request types: PUT, DELETE, HEAD and44OPTIONS? These are all just as simple::Merge pull request #784 from Locker537/docs_fixKenneth Reitzbefore adoptioncb0fdd8
line 45why, one step back45Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 46–65why, one step back46 >>> r = requests.put("http://httpbin.org/put")47 >>> r = requests.delete("http://httpbin.org/delete")48 >>> r = requests.head("http://httpbin.org/get")49 >>> r = requests.options("http://httpbin.org/get")5051That's all well and good, but it's also only the start of what Requests can52do.535455Passing Parameters In URLs56--------------------------5758You often want to send some sort of data in the URL's query string. If59you were constructing the URL by hand, this data would be given as key/value60pairs in the URL after a question mark, e.g. ``httpbin.org/get?key=val``.61Requests allows you to provide these arguments as a dictionary, using the62``params`` keyword argument. As an example, if you wanted to pass63``key1=value1`` and ``key2=value2`` to ``httpbin.org/get``, you would use the64following code::65missed an importKenneth Reitzbefore adoption9427e1e
lines 66–68why, one step back66 >>> payload = {'key1': 'value1', 'key2': 'value2'}67 >>> r = requests.get("http://httpbin.org/get", params=payload)68Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 69why, one step back69You can see that the URL has been correctly encoded by printing the URL::missed an importKenneth Reitzbefore adoption9427e1e
line 70why, one step back70Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 71–72why, one step back71 >>> print r.url72 u'http://httpbin.org/get?key2=value2&key1=value1'missed an importKenneth Reitzbefore adoption9427e1e
line 73why, one step back73Merge pull request #784 from Locker537/docs_fixKenneth Reitzbefore adoptioncb0fdd8
line 74why, one step back74missed an importKenneth Reitzbefore adoption9427e1e
lines 75–77why, one step back75Response Content76----------------77Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 78–79why, one step back78We can read the content of the server's response. Consider the GitHub timeline79again::missed an importKenneth Reitzbefore adoption9427e1e
line 80why, one step back80Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 81–82why, one step back81 >>> import requests82 >>> r = requests.get('https://github.com/timeline.json')missed an importKenneth Reitzbefore adoption9427e1e
lines 83–88why, one step back83 >>> r.text84 '[{"repository":{"open_issues":0,"url":"https://github.com/...8586Requests will automatically decode content from the server. Most unicode87charsets are seamlessly decoded.88Merge pull request #772 from Lukasa/developKenneth Reitzbefore adoption6464618
lines 89–92why, one step back89When you make a request, Requests makes educated guesses about the encoding of90the response based on the HTTP headers. The text encoding guessed by Requests91is used when you access ``r.text``. You can find out what encoding Requests is92using, and change it, using the ``r.encoding`` property::missed an importKenneth Reitzbefore adoption9427e1e
line 93why, one step back93Merge pull request #772 from Lukasa/developKenneth Reitzbefore adoption6464618
lines 94–104why, one step back94 >>> r.encoding95 'utf-8'96 >>> r.encoding = 'ISO-8859-1'9798If you change the encoding, Requests will use the new value of ``r.encoding``99whenever you call ``r.text``.100101Requests will also use custom encodings in the event that you need them. If102you have created your own encoding and registered it with the ``codecs``103module, you can simply use the codec name as the value of ``r.encoding`` and104Requests will handle the decoding for you.missed an importKenneth Reitzbefore adoption9427e1e
lines 105–115why, one step back105106Binary Response Content107-----------------------108109You can also access the response body as bytes, for non-text requests::110111 >>> r.content112 b'[{"repository":{"open_issues":0,"url":"https://github.com/...113114The ``gzip`` and ``deflate`` transfer-encodings are automatically decoded for you.115Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 116why, one step back116For example, to create an image from binary data returned by a request, you canmissed an importKenneth Reitzbefore adoption9427e1e
lines 117–123why, one step back117use the following code:118119 >>> from PIL import Image120 >>> from StringIO import StringIO121 >>> i = Image.open(StringIO(r.content))122123Added r.json documentation (document ALL the awesome features!)Danilo Bargenbefore adoption1164450
lines 124–136why, one step back124JSON Response Content125---------------------126127There's also a builtin JSON decoder, in case you're dealing with JSON data::128129 >>> import requests130 >>> r = requests.get('https://github.com/timeline.json')131 >>> r.json132 [{u'repository': {u'open_issues': 0, u'url': 'https://github.com/...133134In case the JSON decoding fails, ``r.json`` simply returns ``None``.135136missed an importKenneth Reitzbefore adoption9427e1e
lines 137–149why, one step back137Raw Response Content138--------------------139140In the rare case that you'd like to get the absolute raw socket response from the server,141you can access ``r.raw``::142143 >>> r.raw144 <requests.packages.urllib3.response.HTTPResponse object at 0x101194810>145146 >>> r.raw.read(10)147 '\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03'148149Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 150–151why, one step back150Custom Headers151--------------missed an importKenneth Reitzbefore adoption9427e1e
line 152why, one step back152Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 153–154why, one step back153If you'd like to add HTTP headers to a request, simply pass in a ``dict`` to the154``headers`` parameter.missed an importKenneth Reitzbefore adoption9427e1e
line 155why, one step back155Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 156why, one step back156For example, we didn't specify our content-type in the previous example::missed an importKenneth Reitzbefore adoption9427e1e
line 157why, one step back157Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 158–161why, one step back158 >>> import json159 >>> url = 'https://api.github.com/some/endpoint'160 >>> payload = {'some': 'data'}161 >>> headers = {'content-type': 'application/json'}missed an importKenneth Reitzbefore adoption9427e1e
line 162why, one step back162Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 163why, one step back163 >>> r = requests.post(url, data=json.dumps(payload), headers=headers)missed an importKenneth Reitzbefore adoption9427e1e
line 164why, one step back164Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 165–168why, one step back165166More complicated POST requests167------------------------------168missed an importKenneth Reitzbefore adoption9427e1e
lines 169–176why, one step back169Typically, you want to send some form-encoded data — much like an HTML form.170To do this, simply pass a dictionary to the `data` argument. Your171dictionary of data will automatically be form-encoded when the request is made::172173 >>> payload = {'key1': 'value1', 'key2': 'value2'}174 >>> r = requests.post("http://httpbin.org/post", data=payload)175 >>> print r.text176 {Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 177why, one step back177 // ...snip... //missed an importKenneth Reitzbefore adoption9427e1e
lines 178–181why, one step back178 "form": {179 "key2": "value2",180 "key1": "value1"181 },Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 182why, one step back182 // ...snip... //missed an importKenneth Reitzbefore adoption9427e1e
lines 183–188why, one step back183 }184185There are many times that you want to send data that is not form-encoded. If you pass in a ``string`` instead of a ``dict``, that data will be posted directly.186187For example, the GitHub API v3 accepts JSON-Encoded POST/PATCH data::188Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 189–191why, one step back189 >>> import json190 >>> url = 'https://api.github.com/some/endpoint'191 >>> payload = {'some': 'data'}missed an importKenneth Reitzbefore adoption9427e1e
line 192why, one step back192Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 193why, one step back193 >>> r = requests.post(url, data=json.dumps(payload))missed an importKenneth Reitzbefore adoption9427e1e
lines 194–201why, one step back194195196POST a Multipart-Encoded File197-----------------------------198199Requests makes it simple to upload Multipart-encoded files::200201 >>> url = 'http://httpbin.org/post'Merge pull request #752 from anentropic/patch-1Kenneth Reitzbefore adoption54842cd
line 202why, one step back202 >>> files = {'file': open('report.xls', 'rb')}missed an importKenneth Reitzbefore adoption9427e1e
lines 203–206why, one step back203204 >>> r = requests.post(url, files=files)205 >>> r.text206 {Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 207why, one step back207 // ...snip... //missed an importKenneth Reitzbefore adoption9427e1e
line 208why, one step back208 "files": {Merge pull request #752 from anentropic/patch-1Kenneth Reitzbefore adoption54842cd
line 209why, one step back209 "file": "<censored...binary...data>"missed an importKenneth Reitzbefore adoption9427e1e
line 210why, one step back210 },Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 211why, one step back211 // ...snip... //missed an importKenneth Reitzbefore adoption9427e1e
lines 212–213why, one step back212 }213Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 214why, one step back214You can set the filename explicitly::missed an importKenneth Reitzbefore adoption9427e1e
lines 215–221why, one step back215216 >>> url = 'http://httpbin.org/post'217 >>> files = {'file': ('report.xls', open('report.xls', 'rb'))}218219 >>> r = requests.post(url, files=files)220 >>> r.text221 {Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 222why, one step back222 // ...snip... //missed an importKenneth Reitzbefore adoption9427e1e
lines 223–225why, one step back223 "files": {224 "file": "<censored...binary...data>"225 },Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 226why, one step back226 // ...snip... //missed an importKenneth Reitzbefore adoption9427e1e
lines 227–228why, one step back227 }228Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 229why, one step back229If you want, you can send strings to be received as files::Merge remote-tracking branch 'origin/develop' into developKenneth Reitzbefore adoption2a7811b
lines 230–231why, one step back230231 >>> url = 'http://httpbin.org/post'Merge pull request #784 from Locker537/docs_fixKenneth Reitzbefore adoptioncb0fdd8
line 232why, one step back232 >>> files = {'file': ('report.csv', 'some,data,to,send\nanother,row,to,send\n')}Merge remote-tracking branch 'origin/develop' into developKenneth Reitzbefore adoption2a7811b
lines 233–236why, one step back233234 >>> r = requests.post(url, files=files)235 >>> r.text236 {Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 237why, one step back237 // ...snip... //Merge remote-tracking branch 'origin/develop' into developKenneth Reitzbefore adoption2a7811b
lines 238–240why, one step back238 "files": {239 "file": "some,data,to,send\\nanother,row,to,send\\n"240 },Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 241why, one step back241 // ...snip... //Merge remote-tracking branch 'origin/develop' into developKenneth Reitzbefore adoption2a7811b
lines 242–243why, one step back242 }243missed an importKenneth Reitzbefore adoption9427e1e
lines 244–249why, one step back244245Response Status Codes246---------------------247248We can check the response status code::249Merge remote-tracking branch 'origin/develop' into developKenneth Reitzbefore adoption6541ceb
line 250why, one step back250 >>> r = requests.get('http://httpbin.org/get')missed an importKenneth Reitzbefore adoption9427e1e
lines 251–262why, one step back251 >>> r.status_code252 200253254Requests also comes with a built-in status code lookup object for easy255reference::256257 >>> r.status_code == requests.codes.ok258 True259260If we made a bad request (non-200 response), we can raise it with261:class:`Response.raise_for_status()`::262Merge pull request #784 from Locker537/docs_fixKenneth Reitzbefore adoptioncb0fdd8
lines 263–264why, one step back263 >>> bad_r = requests.get('http://httpbin.org/status/404')264 >>> bad_r.status_codemissed an importKenneth Reitzbefore adoption9427e1e
lines 265–266why, one step back265 404266Merge pull request #784 from Locker537/docs_fixKenneth Reitzbefore adoptioncb0fdd8
line 267why, one step back267 >>> bad_r.raise_for_status()missed an importKenneth Reitzbefore adoption9427e1e
line 268why, one step back268 Traceback (most recent call last):Merge pull request #683 from jkleint/patch-1Kenneth Reitzbefore adoption38db8c2
lines 269–271why, one step back269 File "requests/models.py", line 832, in raise_for_status270 raise http_error271 requests.exceptions.HTTPError: 404 Client Errormissed an importKenneth Reitzbefore adoption9427e1e
line 272why, one step back272Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 273–274why, one step back273But, since our ``status_code`` for ``r`` was ``200``, when we call274``raise_for_status()`` we get::missed an importKenneth Reitzbefore adoption9427e1e
lines 275–284why, one step back275276 >>> r.raise_for_status()277 None278279All is well.280281282Response Headers283----------------284Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 285why, one step back285We can view the server's response headers using a Python dictionary::missed an importKenneth Reitzbefore adoption9427e1e
lines 286–324why, one step back286287 >>> r.headers288 {289 'status': '200 OK',290 'content-encoding': 'gzip',291 'transfer-encoding': 'chunked',292 'connection': 'close',293 'server': 'nginx/1.0.4',294 'x-runtime': '148ms',295 'etag': '"e1ca502697e5c9317743dc078f67693f"',296 'content-type': 'application/json; charset=utf-8'297 }298299The dictionary is special, though: it's made just for HTTP headers. According to300`RFC 2616 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html>`_, HTTP301Headers are case-insensitive.302303So, we can access the headers using any capitalization we want::304305 >>> r.headers['Content-Type']306 'application/json; charset=utf-8'307308 >>> r.headers.get('content-type')309 'application/json; charset=utf-8'310311If a header doesn't exist in the Response, its value defaults to ``None``::312313 >>> r.headers['X-Random']314 None315316317Cookies318-------319320If a response contains some Cookies, you can get quick access to them::321322 >>> url = 'http://httpbin.org/cookies/set/requests-is/awesome'323 >>> r = requests.get(url)324update documentation to correspond to new cookie APIShivaram Lingamnenibefore adoptionfdd0821
lines 325–326why, one step back325 >>> r.cookies['requests-is']326 'awesome'missed an importKenneth Reitzbefore adoption9427e1e
lines 327–341why, one step back327328To send your own cookies to the server, you can use the ``cookies``329parameter::330331 >>> url = 'http://httpbin.org/cookies'332 >>> cookies = dict(cookies_are='working')333334 >>> r = requests.get(url, cookies=cookies)335 >>> r.text336 '{"cookies": {"cookies_are": "working"}}'337338339Basic Authentication340--------------------341Merge pull request #787 from kayzh/developKenneth Reitzbefore adoptionbbf1946
line 342why, one step back342Many web services require authentication. There are many different types ofmissed an importKenneth Reitzbefore adoption9427e1e
lines 343–374why, one step back343authentication, but the most common is HTTP Basic Auth.344345Making requests with Basic Auth is extremely simple::346347 >>> from requests.auth import HTTPBasicAuth348 >>> requests.get('https://api.github.com/user', auth=HTTPBasicAuth('user', 'pass'))349 <Response [200]>350351Due to the prevalence of HTTP Basic Auth, requests provides a shorthand for352this authentication method::353354 >>> requests.get('https://api.github.com/user', auth=('user', 'pass'))355 <Response [200]>356357Providing the credentials as a tuple in this fashion is functionally equivalent358to the ``HTTPBasicAuth`` example above.359360361Digest Authentication362---------------------363364Another popular form of web service protection is Digest Authentication::365366 >>> from requests.auth import HTTPDigestAuth367 >>> url = 'http://httpbin.org/digest-auth/auth/user/pass'368 >>> requests.get(url, auth=HTTPDigestAuth('user', 'pass'))369 <Response [200]>370371372OAuth Authentication373--------------------374Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 375–378why, one step back375Miguel Araujo's `requests-oauth <http://pypi.python.org/pypi/requests-oauth>`_376project provides a simple interface for establishing OAuth connections.377Documentation and examples can be found on the requests-oauth378`git repository <https://github.com/maraujop/requests-oauth>`_.missed an importKenneth Reitzbefore adoption9427e1e
lines 379–383why, one step back379380381Redirection and History382-----------------------383Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 384–385why, one step back384Requests will automatically perform location redirection while using the GET385and OPTIONS verbs.missed an importKenneth Reitzbefore adoption9427e1e
line 386why, one step back386Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 387–388why, one step back387GitHub redirects all HTTP requests to HTTPS. We can use the ``history`` method388of the Response object to track redirection. Let's see what Github does::missed an importKenneth Reitzbefore adoption9427e1e
lines 389–398why, one step back389390 >>> r = requests.get('http://github.com')391 >>> r.url392 'https://github.com/'393 >>> r.status_code394 200395 >>> r.history396 [<Response [301]>]397398The :class:`Response.history` list contains a list of theMerge pull request #721 from karlcow/developKenneth Reitzbefore adoptionc3ab38e
line 399why, one step back399:class:`Request` objects that were created in order to complete the request. The list is sorted from the oldest to the most recent request.missed an importKenneth Reitzbefore adoption9427e1e
line 400why, one step back400Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 401–402why, one step back401If you're using GET or OPTIONS, you can disable redirection handling with the402``allow_redirects`` parameter::missed an importKenneth Reitzbefore adoption9427e1e
lines 403–409why, one step back403404 >>> r = requests.get('http://github.com', allow_redirects=False)405 >>> r.status_code406 301407 >>> r.history408 []409Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 410–411why, one step back410If you're using POST, PUT, PATCH, DELETE or HEAD, you can enable411redirection as well::missed an importKenneth Reitzbefore adoption9427e1e
lines 412–422why, one step back412413 >>> r = requests.post('http://github.com', allow_redirects=True)414 >>> r.url415 'https://github.com/'416 >>> r.history417 [<Response [301]>]418419420Timeouts421--------422Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 423–424why, one step back423You can tell requests to stop waiting for a response after a given number of424seconds with the ``timeout`` parameter::missed an importKenneth Reitzbefore adoption9427e1e
lines 425–430why, one step back425426 >>> requests.get('http://github.com', timeout=0.001)427 Traceback (most recent call last):428 File "<stdin>", line 1, in <module>429 requests.exceptions.Timeout: Request timed out.430Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
line 431why, one step back431.. admonition:: Note:missed an importKenneth Reitzbefore adoption9427e1e
line 432why, one step back432Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 433–434why, one step back433 ``timeout`` only effects the connection process itself, not the434 downloading of the response body.missed an importKenneth Reitzbefore adoption9427e1e
lines 435–447why, one step back435436437Errors and Exceptions438---------------------439440In the event of a network problem (e.g. DNS failure, refused connection, etc),441Requests will raise a :class:`ConnectionError` exception.442443In the event of the rare invalid HTTP response, Requests will raise444an :class:`HTTPError` exception.445446If a request times out, a :class:`Timeout` exception is raised.447Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 448–449why, one step back448If a request exceeds the configured number of maximum redirections, a449:class:`TooManyRedirects` exception is raised.missed an importKenneth Reitzbefore adoption9427e1e
lines 450–453why, one step back450451All exceptions that Requests explicitly raises inherit from452:class:`requests.exceptions.RequestException`.453Merge pull request #619 from Lukasa/developKenneth Reitzbefore adoptionad8205f
lines 454–458why, one step back454You can refer to :ref:`Configuration API Docs <configurations>` for immediate455raising of :class:`HTTPError` exceptions via the ``danger_mode`` option or456have Requests catch the majority of457:class:`requests.exceptions.RequestException` exceptions with the ``safe_mode``458option.missed an importKenneth Reitzbefore adoption9427e1e
lines 459–462why, one step back459460-----------------------461462Ready for more? Check out the :ref:`advanced <advanced>` section.