Skip to content
Myr

Merge pull request #333 from bryanhelmig/develop

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Add eager mode for raising errors immediately.

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 4441697, aa39fb0 · Browse files · 5 files+20 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+20 added−0 removed

  • other:+20 added−0 removed

5 files+20 added−0 removed

modified:docs/user/quickstart.rst+4 added
362 unmodified lines
363364All exceptions that Requests explicitly raises inherit from365:class:`requests.exceptions.RequestException`.366367You can refer to :ref:`Configuration API Docs <configurations>` for immediate raising of :class:`HTTPError` exceptions368via the ``danger_mode`` option or have Requests catch the majority of :class:`requests.exceptions.RequestException` exceptions369with the ``safe_mode`` option.370371-----------------------372373Ready for more? Check out the :ref:`advanced <advanced>` section.
modified:requests/defaults.py+2 added
13 unmodified lines
14:max_redirects: Maximum number of redirects allowed within a request.15:decode_unicode: Decode unicode responses automatically?16:keep_alive: Reuse HTTP Connections?17:max_retries: The number of times a request should be retried in the event of a connection failure.18:danger_mode: If true, Requests will raise errors immediately.19:safe_mode: If true, Requests will catch all errors.20:pool_maxsize: The maximium size of an HTTP connection pool.21:pool_connections: The number of active HTTP connection pools to use.22
15 unmodified lines
38defaults['decode_unicode'] = True39defaults['pool_connections'] = 1040defaults['pool_maxsize'] = 1041defaults['max_retries'] = 042defaults['danger_mode'] = False43defaults['safe_mode'] = False44defaults['keep_alive'] = True
modified:requests/models.py+3 added
523 unmodified lines
524 # If prefetch is True, mark content as consumed.525 if prefetch:526 # Save the response.527 self.response.content528 529 if self.config.get('danger_mode'):530 self.response.raise_for_status()531532 return self.sent533534
183 unmodified lines
modified:AUTHORS.rst+1 added
66 unmodified lines
67- Chris Van Horne68- Christopher Davis69- Ori Livneh70- Jason Emerick71- Bryan Helmig
modified:test_requests.py+10 added
277 unmodified lines
278 self.assertFalse(r.error)279 r.raise_for_status()280281282 def test_default_status_raising(self):283 config = {'danger_mode': True}284 args = [httpbin('status', '404')]285 kwargs = dict(config=config)286 self.assertRaises(HTTPError, requests.get, *args, **kwargs)287288 r = requests.get(httpbin('status', '200'))289 self.assertEqual(r.status_code, 200)290291292 def test_decompress_gzip(self):293294 r = requests.get(httpbin('gzip'))295 r.content.decode('ascii')
363 unmodified lines