+ self._log(DBG.HTTP_CTRL, 'connectionLost ' + str(reason))
+ if not reason.check(twisted.web.client.ResponseDone):
+ self._asyncfailure(reason)
+ return
+ try:
+ self._ssd.flush()
+ except Exception as e:
+ self._handleexception()
+
+ def _handleexception(self):
+ self._asyncfailure(traceback.format_exc())
+
+ def _asyncfailure(self, reason):
+ self._log(DBG.HTTP_CTRL, '_asyncFailure ' + str(reason))
+ req_err(self._req, reason)
+
+class ErrorResponseConsumer(twisted.internet.protocol.Protocol):
+ def __init__(self, req, resp):
+ self._req = req
+ self._resp = resp
+
+ try:
+ self._phrase = resp.phrase.decode('utf-8')
+ except Exception:
+ self._phrase = repr(resp.phrase)
+
+ self._log(DBG.HTTP_CTRL, '__init__ %d %s' % (resp.code, self._phrase))
+
+ def _log(self, dflag, msg, **kwargs):
+ log_debug(dflag,'ERROR-RC '+msg, idof=self._req, **kwargs)