]> git.mxchange.org Git - quix0rs-apt-p2p.git/blobdiff - apt_p2p/HTTPDownloader.py
Fixed package loading (which let apt-p2p launch again) + used no more kept-alive...
[quix0rs-apt-p2p.git] / apt_p2p / HTTPDownloader.py
index 9e789b8485fa17e42e47ef371bdaf21115277a1b..243695af4e7e208d27ce47bae36a6eaeeb466244 100644 (file)
@@ -231,7 +231,7 @@ class Peer(ClientFactory):
 
         req, deferRequest, submissionTime = self.request_queue.pop(0)
         try:
-            deferResponse = self.proto.submitRequest(req, False)
+            deferResponse = self.proto.submitRequest(req, True)
         except:
             # Try again later
             log.msg('Got an error trying to submit a new HTTP request %s' % (request.uri, ))
@@ -377,7 +377,7 @@ class Peer(ClientFactory):
 
         # If there are none, then you get 0
         if not self._downloadSpeeds:
-            return 0.0
+            return 150000.0
         
         for download in self._downloadSpeeds:
             total_time += download[1].days*86400.0 + download[1].seconds + download[1].microseconds/1000000.0
@@ -400,7 +400,7 @@ class Peer(ClientFactory):
 
         # If there are none, give it the benefit of the doubt
         if not self._responseTimes:
-            return 0.0
+            return 0.1
 
         for response in self._responseTimes:
             total_response += response[1].days*86400.0 + response[1].seconds + response[1].microseconds/1000000.0
@@ -589,6 +589,32 @@ class TestClientManager(unittest.TestCase):
         d.addCallback(lambda a: self.flushLoggedErrors(TimeoutError))
         return d
         
+    def test_dnserror(self):
+        """Tests a connection timeout."""
+        from twisted.internet.error import DNSLookupError
+        host = 'hureyfnvbfha.debian.net'
+        self.client = Peer(host, 80)
+        self.timeout = 5
+        
+        d = self.client.get('/rfc/rfc0013.txt')
+        d.addCallback(self.gotResp, 1, 1070)
+        d = self.failUnlessFailure(d, DNSLookupError)
+        d.addCallback(lambda a: self.flushLoggedErrors(DNSLookupError))
+        return d
+        
+    def test_noroute(self):
+        """Tests a connection timeout."""
+        from twisted.internet.error import NoRouteError
+        host = '1.2.3.4'
+        self.client = Peer(host, 80)
+        self.timeout = 5
+        
+        d = self.client.get('/rfc/rfc0013.txt')
+        d.addCallback(self.gotResp, 1, 1070)
+        d = self.failUnlessFailure(d, NoRouteError)
+        d.addCallback(lambda a: self.flushLoggedErrors(NoRouteError))
+        return d
+        
     def tearDown(self):
         for p in self.pending_calls:
             if p.active():