Skip to content
Myr

Merge pull request #1935 from cjstapleton/master

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

Add timeout to stream with testing

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 3c4b374, 5f404a0 · Browse files · 2 files+9 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+9 added−4 removed

  • other:+9 added−4 removed

2 files+9 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+8 added
1177 unmodified lines
1178 with pytest.raises(TypeError):1179 morsel_to_cookie(morsel)118011811182class TestTimeout:1183 def test_stream_timeout(self):1184 try:1185 r = requests.get('https://httpbin.org/delay/10', timeout=5.0)1186 except requests.exceptions.Timeout as e:1187 assert 'Read timed out' in e.args[0].args[0]118811891190if __name__ == '__main__':1191 unittest.main()