Skip to content
Myr

Add correct defaults in Session.send()

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

Resolves #1258 Also fixed the tests to reflect the necessary changes.

authored by Ian Cordasco · committed by Ian Cordasco · parent 46a770e · Browse files · 2 files+13 added−4 removed
This commit

State

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

Diff stats

2 files+13 added−4 removed

  • other:+13 added−4 removed

2 files+13 added−4 removed

modified:requests/sessions.py+5 added-3 removed
314 unmodified lines
315 'verify': verify,316 'cert': cert,317 'proxies': proxies,318 'allow_redirects': allow_redirects,319 'req': req,319 }320 resp = self.send(prep, **send_kwargs)321322 # Persist cookies.
73 unmodified lines
396 def send(self, request, **kwargs):397 """Send a given PreparedRequest."""398 # It's possible that users might accidentally send a Request object.399 # Guard against that specific failure case.400 kwargs.setdefault('stream', False)401 kwargs.setdefault('verify', True)402 kwargs.setdefault('proxies', {})403404 if getattr(request, 'prepare', None):405 raise ValueError('You can only send PreparedRequests.')406407 # Set up variables needed for resolve_redirects and dispatching of408 # hooks409 allow_redirects = kwargs.pop('allow_redirects', True)407 req = kwargs.pop('req', None)408 stream = kwargs.get('stream', False)410 stream = kwargs.get('stream')411 timeout = kwargs.get('timeout')412 verify = kwargs.get('verify')413 cert = kwargs.get('cert')414 proxies = kwargs.get('proxies')
64 unmodified lines
modified:test_requests.py+8 added-1 removed
293 unmodified lines
294 'text/py-content-type')})295 self.assertEqual(r.status_code, 200)296 self.assertTrue(b"text/py-content-type" in r.request.body)297298 def test_hook_receives_request_arguments(self):299 def hook(resp, **kwargs):300 assert resp is not None301 assert kwargs != {}302303 requests.Request('GET', HTTPBIN, hooks={'response': hook})304305 def test_prepared_request_hook(self):299 def hook(resp):306 def hook(resp, **kwargs):307 resp.hook_working = True308 return resp309310 req = requests.Request('GET', HTTPBIN, hooks={'response': hook})
94 unmodified lines