X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=apt_p2p%2FHTTPDownloader.py;h=35847f701a433f0f3ea6a505b4ef396d75d3a2ce;hb=05422476cb06c6ccd2def7709a251e618e1eafb3;hp=2952f48cab295ab36381b26983f1c41a58984d2e;hpb=8c18aac4790e10c1126108ab4b71b19e148045db;p=quix0rs-apt-p2p.git diff --git a/apt_p2p/HTTPDownloader.py b/apt_p2p/HTTPDownloader.py index 2952f48..35847f7 100644 --- a/apt_p2p/HTTPDownloader.py +++ b/apt_p2p/HTTPDownloader.py @@ -18,6 +18,9 @@ from zope.interface import implements from apt_p2p_conf import version +class PipelineError(Exception): + """An error has occurred in pipelining requests.""" + class LoggingHTTPClientProtocol(HTTPClientProtocol): """A modified client protocol that logs the number of bytes received.""" @@ -36,6 +39,15 @@ class LoggingHTTPClientProtocol(HTTPClientProtocol): self.stats.receivedBytes(len(data), self.mirror) HTTPClientProtocol.rawDataReceived(self, data) + def setReadPersistent(self, persist): + 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')) + class Peer(ClientFactory): """A manager for all HTTP requests to a single peer.