Commit Graph

758 Commits

Author SHA1 Message Date
VasiliPupkin256 5d6eeb5a7f Map urllib3 ReadTimeoutError to an appropriate ReadTimeout requests exception, issue #2392 2018-01-13 03:28:02 +03:00
Nate Prewitt 37f1d23c39 Merge remote-tracking branch 'upstream/master' into proposed/3.0.0 2017-10-15 13:59:50 -07:00
Mark Szymanski e2f5a135c3 remove legacy super() call 2017-07-26 19:21:45 -05:00
Hugo Osvaldo Barrera 9766870807 Use comprehensions whenever possible 2017-07-14 11:42:32 -03:00
Ed Morley 4847f5b8cd Allow Requests.Response to be used as a context manager
This saves having to wrap the call to requests with
`contextlib.closing()`, allowing it to be used directly in a
`with` statement, like so:

```
with requests.get('http://httpbin.org/get', stream=True) as r:
    # Do things with the response here.
```

Fixes #4136.
2017-06-06 23:30:47 +01:00
Cory Benfield 548823be83 Clean up invalid indentation from merge 2017-05-31 10:41:47 +01:00
Cory Benfield a6f7f5dc62 Clean up flake8 errors from merge 2017-05-31 10:39:27 +01:00
Cory Benfield c3f4a028bf Merge branch 'master' into proposed/3.0.0 2017-05-31 10:29:19 +01:00
kennethreitz 33619268f9 cleanup models.py 2017-05-29 23:00:09 -04:00
kennethreitz 7f14db17c8 new requests namespace 2017-05-29 12:11:43 -04:00
kennethreitz 6d3d5e59c9 fix models.py 2017-05-26 22:55:55 -04:00
kennethreitz 6c41633cfd fix models.py 2017-05-26 22:50:13 -04:00
kennethreitz c3367d1854 remove Request.send(session) 2017-05-26 21:28:52 -04:00
kennethreitz dfd667df96 who wrote this shit 2017-05-26 21:17:13 -04:00
kennethreitz ce64cce14e API improvements 2017-05-26 21:07:37 -04:00
Nate Prewitt a889b62c50 Merge branch 'master' into proposed/3.0.0 2017-05-21 16:25:55 -07:00
Hong Jen-Yee (PCMan) 458df8f4f4 Fix the additional newline generated by iter_lines() caused by a '\r\n' pair being separated in two different chunks. 2017-04-26 23:02:57 +08:00
Chris Gavin 19ba9f1097 Remove some unused imports. 2017-04-25 22:10:01 +01:00
Ruben Dura Tari ead8fba84b Fixes DeprecationWarnings in Python 3.6 due to invalid escape sequences. Fixes #3954 2017-04-05 15:51:58 +01:00
Vincent Barbaresi d491e9f9b2 use [-1] instead of endswith() to work with bytes or string
Also add a parametrize on decode_unicode for iter_lines() test
to check with bytestrings and str content
2017-03-15 22:29:18 +01:00
Vincent Barbaresi 052595ffbf add explanatory comment about skipping null chunks in iter_lines 2017-03-15 12:16:32 +01:00
Vincent Barbaresi cc2ac23c0d remove useless brackets in iter_lines boolean condition 2017-03-15 01:37:55 +01:00
Alex Chan 9881be25f3 Review markups for @Lukasa 2017-03-14 16:57:52 +01:00
Ian Epperson 9174925916 Fix bug when delimiter is split between responses 2017-03-14 16:57:52 +01:00
Nate Prewitt 5a65a0dab1 use InvalidHeader instead of ConflictingHeaderError 2017-03-01 07:32:14 -07:00
Nate Prewitt a52fe6586c consolidate super_len code and cleanup docstrings 2017-02-28 14:51:08 -07:00
Casey Davidson f239fe754d Change UnreachableCodeError to InvalidBodyError. 2017-02-28 14:49:52 -07:00
Casey Davidson 1003fdf0f2 Small fixes based on feedback in pull request. 2017-02-28 14:49:31 -07:00
Casey Davidson 033dfc165d Raise an error if body is not null, has not length and is not streamable. 2017-02-28 14:49:20 -07:00
Casey Davidson bfb202527d Alternate fix for 3066 to refactor prepare_body to always call prepare_content_length.
This allows for the 'Content-Length' header to only be set in prepare_content_length.
2017-02-28 14:49:01 -07:00
Ian Cordasco 8e049bd9eb Update docstrings for Response.__{bool,nonzero}__
Like the docstring added to Response.ok these were misleading and
vaguely incorrect. Better to be explicit than implicit.
2017-02-16 07:21:15 -06:00
Ian Cordasco 7a281e74ec Correct docstring for Response.ok 2017-02-16 07:15:37 -06:00
Mislav Cimperšak 3664682539 added docstring for response.ok property 2017-02-16 10:06:28 +01:00
Rotem Yaari efcbe93075 Make Response.raise_for_status() return the response object if the response is successful
This allows for chaining method calls in cases where we want to raise for bad codes but use the response otherwise,
e.g. requests.get(URL).raise_for_status().json()['value']
2017-02-12 11:11:40 +02:00
Cory Benfield 241f2b2a6b Merge branch 'master' into proposed/3.0.0 2017-02-10 17:40:52 +00:00
Moin fae3f92c34 lazily load idna library 2017-01-17 20:34:15 +05:30
Cory Benfield ba7c464a03 Merge branch 'master' into proposed/3.0.0 2016-12-08 09:16:51 +00:00
Cory Benfield 402a55b647 Revert "Restrict URL preparation to HTTP/HTTPS"
This reverts commit 34af72c87d.
2016-11-30 21:19:31 +00:00
Cory Benfield 5c4549493b Merge pull request #3695 from nateprewitt/idna_bypass
idna bypass
2016-11-25 13:18:01 +00:00
Nicola Soranzo f897be58bf Make Response.content return None if raw is None
Add test.
2016-11-24 12:54:26 +00:00
Nicola Soranzo 4f428228d7 Make Response.content() return None if status_code is None
Fix #3698.
2016-11-23 21:15:07 +00:00
Christian Heimes 34af72c87d Restrict URL preparation to HTTP/HTTPS
Requests treats all URLs starting with the string 'http' as HTTP URLs.
Preparation with IDNA breaks non-standard URIs like http+unix. Requests
now prepares only URLs with prefix http:// and https://.

Signed-off-by: Christian Heimes <christian@python.org>
2016-11-21 18:46:57 +01:00
Nate Prewitt a83685ce00 modifying IDNA encoding check to allow fallback 2016-11-21 08:22:42 -07:00
Hussain 0d7de50dbd Just lstrip instead of strip because trailing whitespace already works. 2016-11-16 23:26:48 +05:30
Hussain 248d3e9f0f Fixed issue #3696. Added a test for it as well. 2016-11-16 22:48:45 +05:30
Nate Prewitt 84d99f01f5 add enforce_content_length=True default 2016-11-15 11:27:29 -07:00
Cory Benfield 7f88aca8f7 Merge branch 'master' into proposed/3.0.0 2016-11-15 17:16:04 +00:00
Chris Martin a49c387b7a Document that Response.json() may raise ValueError 2016-11-10 16:26:07 -05:00
Nate Prewitt 40402cd0dd adding rewind for re-POST bodies 2016-11-02 09:56:56 -06:00
Philipp Konrad 548a03acef requests.post checked data parameters for type like dict.
Changed the type check to Mapping.
2016-10-27 17:57:09 +02:00