Revert "Make safe_mode play nice with timeout (fixes #312)"
authorOri Livneh <ori.livneh@gmail.com>
Thu, 22 Dec 2011 22:36:09 +0000 (17:36 -0500)
committerOri Livneh <ori.livneh@gmail.com>
Thu, 22 Dec 2011 22:42:57 +0000 (17:42 -0500)
This reverts commit 805c4db55413c96c5d6e0f95560119c000f660c9.

requests/models.py
test_requests.py

index f9a9626b37567afc32467c09f70c2cd2ad7319a9..4bef293d3e0f8c4b8a4f1a2b60c1721a89a5709d 100644 (file)
@@ -438,10 +438,6 @@ class Request(object):
                     # Attach Cookie header to request.
                     self.headers['Cookie'] = cookie_header
 
-            # If the request fails but exceptions are suppressed,
-            # we'll build a blank response.
-            r = None
-
             try:
                 # Send the request.
                 r = conn.urlopen(
@@ -462,6 +458,8 @@ class Request(object):
             except MaxRetryError, e:
                 if not self.config.get('safe_mode', False):
                     raise ConnectionError(e)
+                else:
+                    r = None
 
             except (_SSLError, _HTTPError), e:
                 if not self.config.get('safe_mode', False):
@@ -599,7 +597,7 @@ class Response(object):
         def generate():
             chunk = []
 
-            while True:
+            while 1:
                 c = self.raw.read(1)
                 if not c:
                     break
index e547aa64df5f8a6dc3ca433964610839fb72d839..ebcb596d5ac2273597695ca2467a27a6e625e913 100755 (executable)
@@ -619,17 +619,6 @@ class RequestsTestSuite(unittest.TestCase):
         lines = '\n'.join(r.iter_lines())
         self.assertEqual(lines, quote)
 
-    def test_timeout(self):
-
-        # When not in safe mode, should raise Timeout exception
-        with self.assertRaises(requests.exceptions.Timeout):
-            r = requests.get(httpbin('stream', '1000'), timeout=0.0001)
-
-        # In safe mode, should return a blank response
-        r = requests.get(httpbin('stream', '1000'), timeout=0.0001,
-                config=dict(safe_mode=True))
-        self.assertIsNone(r.content)
-
 
 if __name__ == '__main__':
     unittest.main()