Skip to content
Myr

Add timeout to stream with testing

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

Fixes Issue #1803

authored by cjstapleton · committed by cjstapleton · parent e909a92 · Browse files · 2 files+10 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+10 added−4 removed

  • other:+10 added−4 removed

2 files+10 added−4 removed

modified:requests/adapters.py+1 added-4 removed
308 unmodified lines
309 self.add_headers(request)310311 chunked = not (request.body is None or 'Content-Length' in request.headers)312313 if stream:314 timeout = TimeoutSauce(connect=timeout)315 else:316 timeout = TimeoutSauce(connect=timeout, read=timeout)313 timeout = TimeoutSauce(connect=timeout, read=timeout)314315 try:316 if not chunked:317 resp = conn.urlopen(
76 unmodified lines
modified:test_requests.py+9 added
1168 unmodified lines
1169 morsel['max-age'] = 'woops'1170 with pytest.raises(TypeError):1171 morsel_to_cookie(morsel)11721173class TestTimeout:1174 def test_stream_timeout(self):1175 try:1176 r = requests.get('https://httpbin.org/delay/10', timeout=5.0)1177 except requests.exceptions.Timeout as e:1178 assert 'Read timed out' in e.args[0].args[0]117911801181if __name__ == '__main__':1182 unittest.main()11831184