X-Git-Url: https://git.distorted.org.uk/~mdw/hippotat/blobdiff_plain/7b07f0b5fd215702dc58c53bd1cd7c63767f5710..62b51bcf91b1b61b6417fb794272528f2673f3ff:/client diff --git a/client b/client index 39e04c5..c878d72 100755 --- a/client +++ b/client @@ -51,13 +51,26 @@ def outbound(packet, saddr, daddr): queue.append(packet) check_outbound() -def req_ok(data) +class ResponseConsumer(twisted.internet.protocol.Protocol): + def __init__(self): + self._ssd = SlipStreamDecoder(queue_inbound) + def dataReceived(self, data): + self._ssd.inputdata(mime_translate(data)) + def connectionMade(self): pass + def connectionLost(self, reason): + if isinstance(reason, twisted.internet.error.ConnectionDone): + self._ssd.flush() + else: + print(reason, file=sys.stderr) + +def req_ok(resp): + resp.deliverBody(ResponseConsumer()) def req_err(err): print(err, >>sys.stderr) - outstanding-- def req_fin(*args): + outstanding-- def check_outbound(): while True: @@ -83,7 +96,7 @@ def check_outbound(): hh = { 'User-Agent': ['hippotat'], 'Content-Type': ['multipart/form-data; boundary="b"'] } - req = agent.request('POST', + req = agent.request(b'POST', c.url, twisted.web.client.Headers(hh)) req.addTimeout(c.http_timeout,