Skip to content
Myr

Revert "Make safe_mode play nice with timeout (fixes #312)"

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

This reverts commit 805c4db55413c96c5d6e0f95560119c000f660c9.

authored by Ori Livneh · committed by Ori Livneh · parent 12f3c65 · Browse files · 2 files+3 added−16 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+3 added−16 removed

  • other:+3 added−16 removed

2 files+3 added−16 removed

modified:requests/models.py+3 added-5 removed
436 unmodified lines
437438 # Attach Cookie header to request.439 self.headers['Cookie'] = cookie_header440441 # If the request fails but exceptions are suppressed,442 # we'll build a blank response.443 r = None444441 try:442 # Send the request.443 r = conn.urlopen(444 method=self.method,
12 unmodified lines
457458 except MaxRetryError, e:459 if not self.config.get('safe_mode', False):460 raise ConnectionError(e)461 else:462 r = None463464 except (_SSLError, _HTTPError), e:465 if not self.config.get('safe_mode', False):466 raise Timeout('Request timed out.')
129 unmodified lines
596597 def generate():598 chunk = []599602 while True:600 while 1:601 c = self.raw.read(1)602 if not c:603 break604
90 unmodified lines
modified:test_requests.py-11 removed
617 unmodified lines
618 # Make sure iter_lines doesn't chop the trailing bit619 lines = '\n'.join(r.iter_lines())620 self.assertEqual(lines, quote)621622 def test_timeout(self):622624 # When not in safe mode, should raise Timeout exception625 with self.assertRaises(requests.exceptions.Timeout):626 r = requests.get(httpbin('stream', '1000'), timeout=0.0001)627628 # In safe mode, should return a blank response629 r = requests.get(httpbin('stream', '1000'), timeout=0.0001,630 config=dict(safe_mode=True))631 self.assertIsNone(r.content)632633623if __name__ == '__main__':624 unittest.main()