+ def connectionMade(self):
+ self._m = b''
+
+ def dataReceived(self, data):
+ self._log(DBG.HTTP_CTRL, 'dataReceived ' + repr(data))
+ self._m += data
+
+ def connectionLost(self, reason):
+ try:
+ mbody = self._m.decode('utf-8')
+ except Exception:
+ mbody = repr(self._m)
+ if not reason.check(twisted.web.client.ResponseDone):
+ mbody += ' || ' + str(reason)
+ req_err(self._req,
+ "FAILED %d %s | %s"
+ % (self._resp.code, self._phrase, mbody))
+
+def req_ok(req, resp):
+ log_debug(DBG.HTTP_CTRL,
+ 'req_ok %d %s %s' % (resp.code, repr(resp.phrase), str(resp)),
+ idof=req)
+ if resp.code == 200:
+ rc = ResponseConsumer(req)
+ else:
+ rc = ErrorResponseConsumer(req, resp)
+
+ resp.deliverBody(rc)
+
+def req_err(req, err):
+ log_debug(DBG.HTTP_CTRL, 'req_err ' + str(err), idof=req)
+ if isinstance(err, twisted.python.failure.Failure):
+ err = err.getTraceback()