From ebdcf9bd3a4caeb295c3b4f0776af5d16a21982b Mon Sep 17 00:00:00 2001 From: Cameron Dale Date: Fri, 25 Apr 2008 14:43:14 -0700 Subject: [PATCH] Add an optimization to the HTTP client protocol so that pieplining begins sooner. Specifically, it begins after the first requests headers are sent, instead of the whole response. --- apt_p2p/HTTPDownloader.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apt_p2p/HTTPDownloader.py b/apt_p2p/HTTPDownloader.py index 55a818f..d1ea0a9 100644 --- a/apt_p2p/HTTPDownloader.py +++ b/apt_p2p/HTTPDownloader.py @@ -95,13 +95,18 @@ class LoggingHTTPClientProtocol(HTTPClientProtocol): return chanRequest.responseDefer def setReadPersistent(self, persist): + oldPersist = self.readPersistent self.readPersistent = persist if not persist: # Tell all requests but first to abort. lostRequests = self.inRequests[1:] del self.inRequests[1:] for request in lostRequests: - request.connectionLost(PipelineError('The pipelined connection was lost')) + request.connectionLost(PipelineError('Pipelined connection was closed.')) + elif (oldPersist is PERSIST_NO_PIPELINE and + persist is PERSIST_PIPELINE and + self.outRequest is None): + self.manager.clientPipelining(self) def connectionLost(self, reason): self.readPersistent = False @@ -115,7 +120,7 @@ class LoggingHTTPClientProtocol(HTTPClientProtocol): del self.inRequests[1:] for request in lostRequests: if request is not None: - request.connectionLost(reason) + request.connectionLost(PipelineError('Pipelined connection was closed.')) class Peer(ClientFactory): """A manager for all HTTP requests to a single peer. -- 2.30.2