Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add timeout to stream with testing

Fixes Issue #1803
  • Loading branch information...
commit 930f03c8649613da9efb7915e17428dd1e8526af 1 parent e909a92
Cea Stapleton ceaess authored
Showing with 10 additions and 4 deletions.
  1. +1 −4 requests/adapters.py
  2. +9 −0 test_requests.py
5 requests/adapters.py
View
@@ -310,10 +310,7 @@ def send(self, request, stream=False, timeout=None, verify=True, cert=None, prox
chunked = not (request.body is None or 'Content-Length' in request.headers)
- if stream:
- timeout = TimeoutSauce(connect=timeout)
- else:
- timeout = TimeoutSauce(connect=timeout, read=timeout)
+ timeout = TimeoutSauce(connect=timeout, read=timeout)
try:
if not chunked:
9 test_requests.py
View
@@ -1170,6 +1170,15 @@ def test_max_age_invalid_str(self):
with pytest.raises(TypeError):
morsel_to_cookie(morsel)
+class TestTimeout:
+ def test_stream_timeout(self):
+ try:
+ r = requests.get('https://httpbin.org/delay/10', timeout=5.0)
+ except requests.exceptions.Timeout as e:
+ assert 'Read timed out' in e.args[0].args[0]
+
if __name__ == '__main__':
unittest.main()
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.