Ticket #3207: http.py.patch
| File http.py.patch, 2.5 KB (added by camrdale, 5 years ago) |
|---|
-
web2/client/http.py
old new 26 26 Exception raised when a HTTP error happened. 27 27 """ 28 28 29 class PipelineError(Exception): 30 """ 31 Exception raised when a HTTP error happened. 32 """ 33 29 34 30 35 31 36 class ClientRequest(object): … … 82 87 self.closeAfter = closeAfter 83 88 self.transport = self.channel.transport 84 89 self.responseDefer = Deferred() 90 self.started = False 85 91 86 92 def submit(self): 87 93 l = [] … … 152 158 the C{responseDefer} if no response has been sent yet, or close the 153 159 stream. 154 160 """ 155 self.abortParse() 161 if self.started: 162 self.abortParse() 156 163 if hasattr(self, 'stream') and self.stream is not None: 157 164 self.stream.finish(err) 158 165 else: … … 168 175 self._error(reason) 169 176 170 177 def gotInitialLine(self, initialLine): 178 self.started = True 171 179 parts = initialLine.split(' ', 2) 172 180 173 181 # Parse the initial request line … … 346 354 self.transport.loseConnection() 347 355 348 356 def setReadPersistent(self, persist): 357 oldPersist = self.readPersistent 349 358 self.readPersistent = persist 350 359 if not persist: 351 360 # Tell all requests but first to abort. 352 for request in self.inRequests[1:]: 353 request.connectionLost(None) 361 lostRequests = self.inRequests[1:] 354 362 del self.inRequests[1:] 363 for request in lostRequests: 364 request.connectionLost(PipelineError('Pipelined connection was closed.')) 365 elif (oldPersist is PERSIST_NO_PIPELINE and 366 persist is PERSIST_PIPELINE and 367 self.outRequest is None): 368 self.manager.clientPipelining(self) 355 369 356 370 def connectionLost(self, reason): 357 371 self.readPersistent = False 358 372 self.setTimeout(None) 359 373 self.manager.clientGone(self) 360 # Tell all requests to abort. 361 for request in self.inRequests: 374 # Cancel the current request 375 if self.inRequests and self.inRequests[0] is not None: 376 self.inRequests[0].connectionLost(reason) 377 # Tell all remaining requests to abort. 378 lostRequests = self.inRequests[1:] 379 del self.inRequests[1:] 380 for request in lostRequests: 362 381 if request is not None: 363 request.connectionLost( reason)382 request.connectionLost(PipelineError('Pipelined connection was closed.')) 364 383
