+class ResponseConsumer(twisted.internet.protocol.Protocol):
+ def __init__(self):
+ self._ssd = SlipStreamDecoder(queue_inbound)
+ def dataReceived(self, data):
+ try: self._ssd.inputdata(mime_translate(data))
+ except Exception as e: asyncfailure(e)
+ def connectionMade(self): pass
+ def connectionLost(self, reason):
+ if isinstance(reason, twisted.internet.error.ConnectionDone):
+ try: self._ssd.flush()
+ except Exception as e: asyncfailure(e)
+ else:
+ asyncfailure(reason)
+
+def req_ok(resp):
+ resp.deliverBody(ResponseConsumer())
+ req_fin()