Skip to content
Myr

quickstart.rst

This file

Path

docs/user/quickstart.rst

528 lines · 16.8 KiB

Last changed by

Merge pull request #3717 from nateprewitt/streaming_docsCory Benfieldbefore adoptionccabcf1

History of this file

Take it

The walk stopped after 200 commits: lines older than 6143b7e point at it.

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 1–29why, one step back
1.. _quickstart:
23Quickstart4==========56.. module:: requests.models78Eager to get started? This page gives a good introduction in how to get started9with Requests.1011First, make sure that:1213* Requests is :ref:`installed <install>`14* Requests is :ref:`up-to-date <updates>`151617Let's get started with some simple examples.181920Make a Request21--------------2223Making a request with Requests is very simple.2425Begin by importing the Requests module::2627 >>> import requests2829Now, let's try to get a webpage. For this example, let's get GitHub's public

Merge pull request #3513 from nateprewitt/doc_updatesKenneth Reitzbefore adoption786fb19

line 30why, one step back
30timeline::

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 31–39why, one step back
31
32 >>> r = requests.get('https://api.github.com/events')3334Now, we have a :class:`Response <requests.Response>` object called ``r``. We can35get all the information we need from this object.3637Requests' simple API means that all forms of HTTP request are as obvious. For38example, this is how you make an HTTP POST request::39

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 40why, one step back
40 >>> r = requests.post('http://httpbin.org/post', data = {'key':'value'})

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 41–44why, one step back
41
42Nice, right? What about the other HTTP request types: PUT, DELETE, HEAD and43OPTIONS? These are all just as simple::44

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

lines 45–48why, one step back
45 >>> r = requests.put('http://httpbin.org/put', data = {'key':'value'})
46 >>> r = requests.delete('http://httpbin.org/delete')47 >>> r = requests.head('http://httpbin.org/get')48 >>> r = requests.options('http://httpbin.org/get')

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 49–65why, one step back
49
50That's all well and good, but it's also only the start of what Requests can51do.525354Passing Parameters In URLs55--------------------------5657You often want to send some sort of data in the URL's query string. If58you were constructing the URL by hand, this data would be given as key/value59pairs in the URL after a question mark, e.g. ``httpbin.org/get?key=val``.60Requests allows you to provide these arguments as a dictionary, using the61``params`` keyword argument. As an example, if you wanted to pass62``key1=value1`` and ``key2=value2`` to ``httpbin.org/get``, you would use the63following code::6465 >>> payload = {'key1': 'value1', 'key2': 'value2'}

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 66why, one step back
66 >>> r = requests.get('http://httpbin.org/get', params=payload)

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 67–78why, one step back
67
68You can see that the URL has been correctly encoded by printing the URL::6970 >>> print(r.url)71 http://httpbin.org/get?key2=value2&key1=value17273Note that any dictionary key whose value is ``None`` will not be added to the74URL's query string.7576You can also pass a list of items as a value::7778 >>> payload = {'key1': 'value1', 'key2': ['value2', 'value3']}

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

lines 79–80why, one step back
79
80 >>> r = requests.get('http://httpbin.org/get', params=payload)

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 81–90why, one step back
81 >>> print(r.url)
82 http://httpbin.org/get?key1=value1&key2=value2&key2=value38384Response Content85----------------8687We can read the content of the server's response. Consider the GitHub timeline88again::8990 >>> import requests

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 91why, one step back
91

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 92–134why, one step back
92 >>> r = requests.get('https://api.github.com/events')
93 >>> r.text94 u'[{"repository":{"open_issues":0,"url":"https://github.com/...9596Requests will automatically decode content from the server. Most unicode97charsets are seamlessly decoded.9899When you make a request, Requests makes educated guesses about the encoding of100the response based on the HTTP headers. The text encoding guessed by Requests101is used when you access ``r.text``. You can find out what encoding Requests is102using, and change it, using the ``r.encoding`` property::103104 >>> r.encoding105 'utf-8'106 >>> r.encoding = 'ISO-8859-1'107108If you change the encoding, Requests will use the new value of ``r.encoding``109whenever you call ``r.text``. You might want to do this in any situation where110you can apply special logic to work out what the encoding of the content will111be. For example, HTTP and XML have the ability to specify their encoding in112their body. In situations like this, you should use ``r.content`` to find the113encoding, and then set ``r.encoding``. This will let you use ``r.text`` with114the correct encoding.115116Requests will also use custom encodings in the event that you need them. If117you have created your own encoding and registered it with the ``codecs``118module, you can simply use the codec name as the value of ``r.encoding`` and119Requests will handle the decoding for you.120121Binary Response Content122-----------------------123124You can also access the response body as bytes, for non-text requests::125126 >>> r.content127 b'[{"repository":{"open_issues":0,"url":"https://github.com/...128129The ``gzip`` and ``deflate`` transfer-encodings are automatically decoded for you.130131For example, to create an image from binary data returned by a request, you can132use the following code::133134 >>> from PIL import Image

Merge pull request #3511 from forrestchang/masterCory Benfieldbefore adoptionf12166a

line 135why, one step back
135 >>> from io import BytesIO

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 136why, one step back
136

Merge pull request #3511 from forrestchang/masterCory Benfieldbefore adoptionf12166a

line 137why, one step back
137 >>> i = Image.open(BytesIO(r.content))

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 138–145why, one step back
138
139140JSON Response Content141---------------------142143There's also a builtin JSON decoder, in case you're dealing with JSON data::144145 >>> import requests

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 146why, one step back
146

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 147–150why, one step back
147 >>> r = requests.get('https://api.github.com/events')
148 >>> r.json()149 [{u'repository': {u'open_issues': 0, u'url': 'https://github.com/...150

Merge pull request #3513 from nateprewitt/doc_updatesKenneth Reitzbefore adoption786fb19

line 151why, one step back
151In case the JSON decoding fails, ``r.json()`` raises an exception. For example, if

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

line 152why, one step back
152the response gets a 204 (No Content), or if the response contains invalid JSON,

Merge pull request #3513 from nateprewitt/doc_updatesKenneth Reitzbefore adoption786fb19

line 153why, one step back
153attempting ``r.json()`` raises ``ValueError: No JSON object could be decoded``.

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

line 154why, one step back
154

Merge pull request #3513 from nateprewitt/doc_updatesKenneth Reitzbefore adoption786fb19

line 155why, one step back
155It should be noted that the success of the call to ``r.json()`` does **not**

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 156–169why, one step back
156indicate the success of the response. Some servers may return a JSON object in a
157failed response (e.g. error details with HTTP 500). Such JSON will be decoded158and returned. To check that a request is successful, use159``r.raise_for_status()`` or check ``r.status_code`` is what you expect.160161162Raw Response Content163--------------------164165In the rare case that you'd like to get the raw socket response from the166server, you can access ``r.raw``. If you want to do this, make sure you set167``stream=True`` in your initial request. Once you do, you can do this::168169 >>> r = requests.get('https://api.github.com/events', stream=True)

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 170why, one step back
170

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 171–172why, one step back
171 >>> r.raw
172 <requests.packages.urllib3.response.HTTPResponse object at 0x101194810>

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 173why, one step back
173

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 174–180why, one step back
174 >>> r.raw.read(10)
175 '\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03'176177In general, however, you should use a pattern like this to save what is being178streamed to a file::179180 with open(filename, 'wb') as fd:

Merge pull request #3717 from nateprewitt/streaming_docsCory Benfieldbefore adoptionccabcf1

line 181why, one step back
181 for chunk in r.iter_content(chunk_size=128):

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 182–186why, one step back
182 fd.write(chunk)
183184Using ``Response.iter_content`` will handle a lot of what you would otherwise185have to handle when using ``Response.raw`` directly. When streaming a186download, the above is the preferred and recommended way to retrieve the

Merge pull request #3717 from nateprewitt/streaming_docsCory Benfieldbefore adoptionccabcf1

lines 187–188why, one step back
187content. Note that ``chunk_size`` can be freely adjusted to a number that
188may better fit your use cases.

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 189–214why, one step back
189
190191Custom Headers192--------------193194If you'd like to add HTTP headers to a request, simply pass in a ``dict`` to the195``headers`` parameter.196197For example, we didn't specify our user-agent in the previous example::198199 >>> url = 'https://api.github.com/some/endpoint'200 >>> headers = {'user-agent': 'my-app/0.0.1'}201202 >>> r = requests.get(url, headers=headers)203204Note: Custom headers are given less precedence than more specific sources of information. For instance:205206* Authorization headers set with `headers=` will be overridden if credentials207 are specified in ``.netrc``, which in turn will be overridden by the ``auth=``208 parameter.209* Authorization headers will be removed if you get redirected off-host.210* Proxy-Authorization headers will be overridden by proxy credentials provided in the URL.211* Content-Length headers will be overridden when we can determine the length of the content.212213Furthermore, Requests does not change its behavior at all based on which custom headers are specified. The headers are simply passed on into the final request.214

Merge pull request #3388 from nateprewitt/header_doc_updateIan Cordascobefore adoption5d9b9ff

line 215why, one step back
215Note: All header values must be a ``string``, bytestring, or unicode. While permitted, it's advised to avoid passing unicode header values.

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 216–224why, one step back
216
217More complicated POST requests218------------------------------219220Typically, you want to send some form-encoded data — much like an HTML form.221To do this, simply pass a dictionary to the ``data`` argument. Your222dictionary of data will automatically be form-encoded when the request is made::223224 >>> payload = {'key1': 'value1', 'key2': 'value2'}

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 225why, one step back
225

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 226–242why, one step back
226 >>> r = requests.post("http://httpbin.org/post", data=payload)
227 >>> print(r.text)228 {229 ...230 "form": {231 "key2": "value2",232 "key1": "value1"233 },234 ...235 }236237There are many times that you want to send data that is not form-encoded. If238you pass in a ``string`` instead of a ``dict``, that data will be posted directly.239240For example, the GitHub API v3 accepts JSON-Encoded POST/PATCH data::241242 >>> import json

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 243why, one step back
243

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 244–309why, one step back
244 >>> url = 'https://api.github.com/some/endpoint'
245 >>> payload = {'some': 'data'}246247 >>> r = requests.post(url, data=json.dumps(payload))248249Instead of encoding the ``dict`` yourself, you can also pass it directly using250the ``json`` parameter (added in version 2.4.2) and it will be encoded automatically::251252 >>> url = 'https://api.github.com/some/endpoint'253 >>> payload = {'some': 'data'}254255 >>> r = requests.post(url, json=payload)256257258POST a Multipart-Encoded File259-----------------------------260261Requests makes it simple to upload Multipart-encoded files::262263 >>> url = 'http://httpbin.org/post'264 >>> files = {'file': open('report.xls', 'rb')}265266 >>> r = requests.post(url, files=files)267 >>> r.text268 {269 ...270 "files": {271 "file": "<censored...binary...data>"272 },273 ...274 }275276You can set the filename, content_type and headers explicitly::277278 >>> url = 'http://httpbin.org/post'279 >>> files = {'file': ('report.xls', open('report.xls', 'rb'), 'application/vnd.ms-excel', {'Expires': '0'})}280281 >>> r = requests.post(url, files=files)282 >>> r.text283 {284 ...285 "files": {286 "file": "<censored...binary...data>"287 },288 ...289 }290291If you want, you can send strings to be received as files::292293 >>> url = 'http://httpbin.org/post'294 >>> files = {'file': ('report.csv', 'some,data,to,send\nanother,row,to,send\n')}295296 >>> r = requests.post(url, files=files)297 >>> r.text298 {299 ...300 "files": {301 "file": "some,data,to,send\\nanother,row,to,send\\n"302 },303 ...304 }305306In the event you are posting a very large file as a ``multipart/form-data``307request, you may want to stream the request. By default, ``requests`` does not308support this, but there is a separate package which does -309``requests-toolbelt``. You should read `the toolbelt's documentation

Merge pull request #3136 from Natim/readthedocs.ioCory Benfieldbefore adoption252bfa7

line 310why, one step back
310<https://toolbelt.readthedocs.io>`_ for more details about how to use it.

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 311–419why, one step back
311
312For sending multiple files in one request refer to the :ref:`advanced <advanced>`313section.314315.. warning:: It is strongly recommended that you open files in `binary mode`_.316 This is because Requests may attempt to provide the317 ``Content-Length`` header for you, and if it does this value will318 be set to the number of *bytes* in the file. Errors may occur if319 you open the file in *text mode*.320321.. _binary mode: https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files322323324Response Status Codes325---------------------326327We can check the response status code::328329 >>> r = requests.get('http://httpbin.org/get')330 >>> r.status_code331 200332333Requests also comes with a built-in status code lookup object for easy334reference::335336 >>> r.status_code == requests.codes.ok337 True338339If we made a bad request (a 4XX client error or 5XX server error response), we340can raise it with341:meth:`Response.raise_for_status() <requests.Response.raise_for_status>`::342343 >>> bad_r = requests.get('http://httpbin.org/status/404')344 >>> bad_r.status_code345 404346347 >>> bad_r.raise_for_status()348 Traceback (most recent call last):349 File "requests/models.py", line 832, in raise_for_status350 raise http_error351 requests.exceptions.HTTPError: 404 Client Error352353But, since our ``status_code`` for ``r`` was ``200``, when we call354``raise_for_status()`` we get::355356 >>> r.raise_for_status()357 None358359All is well.360361362Response Headers363----------------364365We can view the server's response headers using a Python dictionary::366367 >>> r.headers368 {369 'content-encoding': 'gzip',370 'transfer-encoding': 'chunked',371 'connection': 'close',372 'server': 'nginx/1.0.4',373 'x-runtime': '148ms',374 'etag': '"e1ca502697e5c9317743dc078f67693f"',375 'content-type': 'application/json'376 }377378The dictionary is special, though: it's made just for HTTP headers. According to379`RFC 7230 <http://tools.ietf.org/html/rfc7230#section-3.2>`_, HTTP Header names380are case-insensitive.381382So, we can access the headers using any capitalization we want::383384 >>> r.headers['Content-Type']385 'application/json'386387 >>> r.headers.get('content-type')388 'application/json'389390It is also special in that the server could have sent the same header multiple391times with different values, but requests combines them so they can be392represented in the dictionary within a single mapping, as per393`RFC 7230 <http://tools.ietf.org/html/rfc7230#section-3.2>`_:394395 A recipient MAY combine multiple header fields with the same field name396 into one "field-name: field-value" pair, without changing the semantics397 of the message, by appending each subsequent field value to the combined398 field value in order, separated by a comma.399400Cookies401-------402403If a response contains some Cookies, you can quickly access them::404405 >>> url = 'http://example.com/some/cookie/setting/url'406 >>> r = requests.get(url)407408 >>> r.cookies['example_cookie_name']409 'example_cookie_value'410411To send your own cookies to the server, you can use the ``cookies``412parameter::413414 >>> url = 'http://httpbin.org/cookies'415 >>> cookies = dict(cookies_are='working')416417 >>> r = requests.get(url, cookies=cookies)418 >>> r.text419 '{"cookies": {"cookies_are": "working"}}'

Merge pull request #3511 from forrestchang/masterCory Benfieldbefore adoptionf12166a

line 420why, one step back
420

Merge pull request #3469 from roselma/patch-1Cory Benfieldbefore adoptioncf7fdb9

lines 421–426why, one step back
421Cookies are returned in a :class:`~requests.cookies.RequestsCookieJar`,
422which acts like a ``dict`` but also offers a more complete interface,423suitable for use over multiple domains or paths. Cookie jars can424also be passed in to requests::425426 >>> jar = requests.cookies.RequestsCookieJar()

Merge pull request #3691 from Cleod9/readme-typo-domain-argCory Benfieldbefore adoption341f288

lines 427–428why, one step back
427 >>> jar.set('tasty_cookie', 'yum', domain='httpbin.org', path='/cookies')
428 >>> jar.set('gross_cookie', 'blech', domain='httpbin.org', path='/elsewhere')

Merge pull request #3469 from roselma/patch-1Cory Benfieldbefore adoptioncf7fdb9

lines 429–432why, one step back
429 >>> url = 'http://httpbin.org/cookies'
430 >>> r = requests.get(url, cookies=jar)431 >>> r.text432 '{"cookies": {"tasty_cookie": "yum"}}'

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 433–442why, one step back
433
434435Redirection and History436-----------------------437438By default Requests will perform location redirection for all verbs except439HEAD.440441We can use the ``history`` property of the Response object to track redirection.442

Merge pull request #3513 from nateprewitt/doc_updatesKenneth Reitzbefore adoption786fb19

line 443why, one step back
443The :attr:`Response.history <requests.Response.history>` list contains the

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 444–450why, one step back
444:class:`Response <requests.Response>` objects that were created in order to
445complete the request. The list is sorted from the oldest to the most recent446response.447448For example, GitHub redirects all HTTP requests to HTTPS::449450 >>> r = requests.get('http://github.com')

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 451why, one step back
451

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 452–453why, one step back
452 >>> r.url
453 'https://github.com/'

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 454why, one step back
454

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 455–456why, one step back
455 >>> r.status_code
456 200

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 457why, one step back
457

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 458–465why, one step back
458 >>> r.history
459 [<Response [301]>]460461462If you're using GET, OPTIONS, POST, PUT, PATCH or DELETE, you can disable463redirection handling with the ``allow_redirects`` parameter::464465 >>> r = requests.get('http://github.com', allow_redirects=False)

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 466why, one step back
466

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 467–468why, one step back
467 >>> r.status_code
468 301

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 469why, one step back
469

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 470–475why, one step back
470 >>> r.history
471 []472473If you're using HEAD, you can enable redirection as well::474475 >>> r = requests.head('http://github.com', allow_redirects=True)

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 476why, one step back
476

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 477–478why, one step back
477 >>> r.url
478 'https://github.com/'

cleanup quickstartKenneth Reitzbefore adoptionbf8c831

line 479why, one step back
479

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 480–487why, one step back
480 >>> r.history
481 [<Response [301]>]482483484Timeouts485--------486487You can tell Requests to stop waiting for a response after a given number of

Merge pull request #3679 from mlissner/patch-2Cory Benfieldbefore adoptione2408fc

lines 488–490why, one step back
488seconds with the ``timeout`` parameter. Nearly all production code should use
489this parameter in nearly all requests. Failure to do so can cause your program490to hang indefinitely::

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 491–502why, one step back
491
492 >>> requests.get('http://github.com', timeout=0.001)493 Traceback (most recent call last):494 File "<stdin>", line 1, in <module>495 requests.exceptions.Timeout: HTTPConnectionPool(host='github.com', port=80): Request timed out. (timeout=0.001)496497498.. admonition:: Note499500 ``timeout`` is not a time limit on the entire response download;501 rather, an exception is raised if the server has not issued a502 response for ``timeout`` seconds (more precisely, if no bytes have been

Merge pull request #3520 from Brausepaul/masterKenneth Reitzbefore adoption33501c7

lines 503–504why, one step back
503 received on the underlying socket for ``timeout`` seconds). If no timeout is specified explicitly, requests do
504 not time out.

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 505–510why, one step back
505
506507Errors and Exceptions508---------------------509510In the event of a network problem (e.g. DNS failure, refused connection, etc),

Merge pull request #3513 from nateprewitt/doc_updatesKenneth Reitzbefore adoption786fb19

line 511why, one step back
511Requests will raise a :exc:`~requests.exceptions.ConnectionError` exception.

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

line 512why, one step back
512

Merge pull request #3297 from davidfischer/http-error-specificsKenneth Reitzbefore adoptione12ee94

line 513why, one step back
513:meth:`Response.raise_for_status() <requests.Response.raise_for_status>` will

Merge pull request #3513 from nateprewitt/doc_updatesKenneth Reitzbefore adoption786fb19

line 514why, one step back
514raise an :exc:`~requests.exceptions.HTTPError` if the HTTP request

Merge pull request #3297 from davidfischer/http-error-specificsKenneth Reitzbefore adoptione12ee94

line 515why, one step back
515returned an unsuccessful status code.

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

line 516why, one step back
516

Merge pull request #3513 from nateprewitt/doc_updatesKenneth Reitzbefore adoption786fb19

line 517why, one step back
517If a request times out, a :exc:`~requests.exceptions.Timeout` exception is

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 518–520why, one step back
518raised.
519520If a request exceeds the configured number of maximum redirections, a

Merge pull request #3513 from nateprewitt/doc_updatesKenneth Reitzbefore adoption786fb19

line 521why, one step back
521:exc:`~requests.exceptions.TooManyRedirects` exception is raised.

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 522–523why, one step back
522
523All exceptions that Requests explicitly raises inherit from

Merge pull request #3513 from nateprewitt/doc_updatesKenneth Reitzbefore adoption786fb19

line 524why, one step back
524:exc:`requests.exceptions.RequestException`.

Merge pull request #2994 from Stranger6667/fix-bad-testCory Benfieldbefore adoption6143b7e

lines 525–528why, one step back
525
526-----------------------527528Ready for more? Check out the :ref:`advanced <advanced>` section.