Commit Graph

4358 Commits

Author SHA1 Message Date
Kevin Burke ae1ac2d4e0 Flip conditional in session.send()
Previously we checked that the `request` being sent was an instance of a
PreparedRequest. If a user somehow created a PreparedRequest using a different
Requests library instance, this check makes the request un-sendable.

(This happened recently - unbeknownst to me, my server was running an outdated
version of pip, vulnerable to this issue - pypa/pip#1489, which creates
multiple subdirectories (src/requests, src/requests/requests) when you rerun
pip install --target. So the PreparedRequest was being created in one version
of the library and compared against the other version of the library, and
throwing this exception, even though they were both PreparedRequest instances!)

It would probably be preferable to check the object's behavior (instead of
its type), but a PreparedRequest has a lot of behavior, and it wouldn't be
really feasible or allow us to provide a helpful error message to check all
of it here. Instead flip the conditional to guard against the user sending an
unprepared Request, which should still give us most of the benefits of the
better error message.

Fixes #3102
2016-04-21 08:12:05 -07:00
kennethreitz aa1c3adf9a Merge pull request #3100 from hitstergtd/hitstergtd-docfixes-1
Remove stale sentence in philosophy.rst
2016-04-17 13:26:24 -04:00
Hitster GTD d801d7797e Remove stale sentence in philosophy.rst
Sentence contained reference to version 1.0.0.
2016-04-16 10:57:24 +01:00
Ian Cordasco 60aee145b9 Merge pull request #3091 from bodgit/proxy
Clear any pooled proxy connections
2016-04-15 07:50:06 -05:00
Matt Dainty 2029a8a931 Clear any pooled proxy connections
As well as clearing any pooled direct connections, iterate over any
ProxyManager objects and clear any pooled proxy connections there as well.
2016-04-15 09:33:37 +01:00
kennethreitz 4a716e0dfc Merge pull request #2897 from BraulioVM/dummy-server
Test socket server
2016-04-11 16:29:02 -04:00
Braulio Valdivielso Martínez 634b2beb39 Fixed indenting issues 2016-04-11 20:03:23 +02:00
Ian Cordasco e65d6fc637 Merge pull request #3082 from tzickel/master
Added a test to show a faulty behaviour when posting binary data for an object with no __iter__
2016-04-11 07:38:50 -05:00
Cory Benfield b5d375417f Merge pull request #3086 from sleshep/master
add rtype in session.request,help pycharm easy.
2016-04-11 08:14:39 +01:00
liuyang 2981366f56 add rtype in session.request 2016-04-11 14:33:23 +08:00
kennethreitz 2874fd18fe Merge pull request #3080 from Lukasa/rfc7838
Add 421 Misdirected Request.
2016-04-10 16:49:27 -04:00
tzickel 219490ea7f Make a dummy test 2016-04-08 23:17:37 +03:00
tzickel fb230709a8 Fix for the test ? 2016-04-08 22:23:35 +03:00
tzickel 2246a52a36 Added a test to show a faulty behaviour when posting binary data for an object
with no __iter__
2016-04-08 20:25:01 +03:00
Cory Benfield 831d8e0a1e Add 421 Misdirected Request. 2016-04-08 08:23:46 +01:00
kennethreitz f0860bd3ca Merge pull request #3048 from Stranger6667/test-structures
Added unit tests for structures module
2016-04-06 15:06:36 -04:00
kennethreitz 456be3cfde Merge pull request #3024 from Stranger6667/utils-unit-tests
Added unit tests for utils module
2016-04-06 15:05:13 -04:00
kennethreitz b6b1b3a81c Merge pull request #3049 from Stranger6667/test-hooks
Added unit tests for hooks module
2016-04-06 15:04:15 -04:00
kennethreitz 90578795eb Update HISTORY.rst 2016-04-06 15:02:06 -04:00
kennethreitz 03ed671a41 Merge pull request #3059 from alexanderad/proxy-connection-errors
Raise a ProxyError for proxy related connection issues
2016-04-06 15:01:25 -04:00
Cory Benfield e576f98429 Merge pull request #3069 from achermes/master
Update docstring and API doc to document ability to add per-file headers in multipart POST
2016-03-29 12:31:57 +01:00
Alexander Hermes b8a577050d Update docstring and API doc to document ability to add per-file headers in multipart POST
* Docstring only change - for the function itself cf. requests Issue #1640
2016-03-29 11:57:47 +01:00
Ian Cordasco 3acf3a7238 Merge pull request #3060 from benweatherman/master
Consolidate logic for changing method during redirects
2016-03-20 13:46:00 -05:00
Ben f24d56a1ce Consolidate logic for changing method during redirects
I only moved the code into a function, there was no actual change to
the code. I added a few tests to ensure we're doing things correctly.

The real point of me doing this is to make it easier to bring back
`strict_mode` functionality. For you requests youngsters in the crowd,
`strict_mode` followed the spec for redirects meaning the method
wouldn't change to a GET. The current code follows the browser
convention of changing the method to a GET when doing a 302 redirect.
However, lots of servers want you to follow the standards (the nerve!)
so I'd like to override the logic. Now that the method changing logic
is in `rebuild_method`, I can simply override that function instead of
overriding the entire `resolve_redirects` function as suggested by
kennethreitz/requests#1325
2016-03-17 23:16:39 -05:00
Alexander Shchapov 6ca9d71bb5 Raise a ProxyError for proxy related connection issues. 2016-03-17 15:46:26 -04:00
Cory Benfield c9f8414476 Merge pull request #3057 from kevinburke/secure-by-default
Clarify that SSL verification is on by default
2016-03-17 15:19:59 +00:00
Kevin Burke e94c812c2d Clarify that SSL verification is on by default
Generally if a kwarg is present it indicates that an option other than the
default is being specified. Putting `verify=True` in the first code sample
for SSL confused me, because it seemed to indicate that you had to specify
`verify=True` to get SSL verification. The opposite is true; SSL verification
is turned on by default and you have to specify `verify=False` to opt out of
SSL verification.

Updates the docs to make this more clear. Furthermore, connections to
https://kennethreitz.com currently time out instead of presenting an invalid
certificate, so I replaced this domain with https://requestb.in, which presents
the same error message as is currently there.
2016-03-17 08:16:56 -07:00
Dmitry Dygalo 81dc9084b2 Added unit tests for structures module 2016-03-15 14:47:32 +01:00
Dmitry Dygalo eddea4e914 Added unit tests for hooks module 2016-03-14 14:08:44 +01:00
Dmitry Dygalo 1eb153529a Merge remote-tracking branch 'upstream/master' into utils-unit-tests
Conflicts:
	tests/test_utils.py
2016-03-13 10:24:47 +01:00
Ian Cordasco 190cddd4ae Merge pull request #3036 from Lukasa/issue/3035
Allow for exceptions from tell()
2016-03-11 07:30:53 -06:00
Cory Benfield 90a166d44a Release note. 2016-03-11 09:57:59 +00:00
kennethreitz 3a26d13b52 Merge pull request #3041 from bsandrow/patch-2
Fix autofunction Reference
2016-03-09 03:59:44 -05:00
kennethreitz fe475f5d46 Merge pull request #3042 from bsandrow/patch-1
Fix api.rst References
2016-03-09 00:35:45 -05:00
Brandon Sandrowicz f0d5a1f230 Fix autofunction Reference
`request.codes` is a class (`LookupDict`), not a function.
2016-03-08 23:57:54 -05:00
Brandon Sandrowicz ee060ba7f3 Fix api.rst References
api.rst references `requests.ConnectTimeout` and `requests.ReadTimeout`, but they aren't imported into the top-level of the package.
2016-03-08 23:51:46 -05:00
Braulio Valdivielso Martínez b473440cc1 Fix tests in python 3 2016-03-07 18:33:06 +01:00
Cory Benfield 6cc0b56d51 Switch to treat files without tell() as zero-length 2016-03-07 09:05:43 +00:00
Cory Benfield e034dd1140 Allow for exceptions from tell() 2016-03-07 08:31:23 +00:00
Cory Benfield 4f378b0e1a Merge pull request #3032 from davidsoncasey/master
Changes for #3028
2016-03-06 18:07:59 +00:00
Casey Davidson f74a6707af Verify that cookie can be properly accessed if domain is specified, and that error is raised otherwise. Refs #3028. 2016-03-05 20:37:56 -08:00
Casey Davidson c53a685e7d Fix typo. 2016-03-05 20:30:36 -08:00
Braulio Valdivielso Martínez 03743b15ed Added docstrings to tests in test_testserver.py 2016-03-05 23:50:11 +01:00
Braulio Valdivielso Martínez 0dff06a7b9 Add blank line in test_requests.py 2016-03-05 23:28:32 +01:00
Braulio Valdivielso Martínez c4abb4c9fb Remove unwanted changes in test_utils.py 2016-03-05 23:26:36 +01:00
Braulio Valdivielso Martínez 94d4818fde Remove unwanted change in test_requests.py 2016-03-05 23:22:52 +01:00
Braulio Valdivielso Martínez eeafdc143b Move test_chunked_upload to test_lowlevel.py 2016-03-05 23:21:00 +01:00
Braulio Valdivielso Martínez 66c52c3ce0 Leave two lines of separation between top level definitions 2016-03-05 23:11:31 +01:00
Braulio Valdivielso Martínez 3c3bde5381 Remove unwanted changes 2016-03-05 23:10:13 +01:00
Braulio Valdivielso Martínez 4edf1ae55f Compare response bodies with unicode strings 2016-03-05 23:05:36 +01:00