From: Ian Jackson Date: Tue, 22 Aug 2017 16:37:06 +0000 (+0100) Subject: ResponseConsumer: break out connectionLostOK into superclass X-Git-Url: https://git.distorted.org.uk/~mdw/hippotat/commitdiff_plain/216519e342072164533ae340141d585c638db8e2 ResponseConsumer: break out connectionLostOK into superclass Signed-off-by: Ian Jackson --- diff --git a/hippotat b/hippotat index abe1cae..200cf3a 100755 --- a/hippotat +++ b/hippotat @@ -42,6 +42,9 @@ class GeneralResponseConsumer(twisted.internet.protocol.Protocol): def connectionMade(self): self._log(DBG.HTTP_CTRL, 'connectionMade') + def connectionLostOK(self, reason): + return reason.check(twisted.web.client.ResponseDone) + class ResponseConsumer(GeneralResponseConsumer): def __init__(self, cl, req, resp): super().__init__(cl, req, resp, 'RC') @@ -59,7 +62,7 @@ class ResponseConsumer(GeneralResponseConsumer): def connectionLost(self, reason): reason_msg = 'connectionLost ' + str(reason) self._log(DBG.HTTP_CTRL, reason_msg) - if not reason.check(twisted.web.client.ResponseDone): + if not self.connectionLostOK(reason): self._latefailure(reason_msg) return try: @@ -96,7 +99,7 @@ class ErrorResponseConsumer(GeneralResponseConsumer): mbody = self._m.decode('utf-8') except Exception: mbody = repr(self._m) - if not reason.check(twisted.web.client.ResponseDone): + if not self.connectionLostOK(reason): mbody += ' || ' + str(reason) self._cl.req_err(self._req, "FAILED %d %s | %s"