X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=client;h=5dbae1c6bbc3255b2ef7d2017579d74140d916b3;hb=14c6d55c17a81e119a038980067d93078a4cde75;hp=436592eefcaf3920221c587747a3cf21f6534c07;hpb=60dc70f9314c87b6d12fc248aa05b74996ae28ef;p=hippotat.git diff --git a/client b/client index 436592e..5dbae1c 100755 --- a/client +++ b/client @@ -5,6 +5,8 @@ from hippotat import * import twisted.web import twisted.web.client +import io + client_cs = None def set_client(ci,cs,pw): @@ -57,8 +59,14 @@ def outbound(packet, saddr, daddr): check_outbound() class ResponseConsumer(twisted.internet.protocol.Protocol): - def __init__(self): + def __init__(self, req): + self._req = req self._ssd = SlipStreamDecoder(queue_inbound) + self._log(DBG.HTTP_CTRL, '__init__') + + def _log(self, dflag, msg, **kwargs): + log_debug(dflag, 'RC ' + msg, idof=self._req, **kwargs) + def dataReceived(self, data): try: self._ssd.inputdata(mime_translate(data)) except Exception as e: asyncfailure(e) @@ -70,8 +78,9 @@ class ResponseConsumer(twisted.internet.protocol.Protocol): else: asyncfailure(reason) -def req_ok(resp): - resp.deliverBody(ResponseConsumer()) +def req_ok(req, resp): + rc = ResponseConsumer(req) + resp.deliverBody(rc) req_fin() def req_err(err): @@ -101,33 +110,45 @@ def check_outbound(): moredata, c.max_batch_up) + d = mime_translate(d) + crlf = b'\r\n' lf = b'\n' - mime = (b'--b' + crlf + - b'Content-Disposition: form-data; name="m"' + crlf + crlf + - password + lf + - str(c.client) .encode('ascii') + lf + - str(c.target_outstanding) .encode('ascii') + crlf + + mime = (b'--b' + crlf + + b'Content-Type: text/plain; charset="utf-8"' + crlf + + b'Content-Disposition: form-data; name="m"' + crlf + crlf + + str(c.client) .encode('ascii') + crlf + + password + crlf + + str(c.target_outstanding) .encode('ascii') + crlf + (( - b'--b' + crlf + - b'Content-Disposition: form-data; name="d"' + crlf + crlf + - mime_translate(d) + crlf + b'--b' + crlf + + b'Content-Type: application/octet-stream' + crlf + + b'Content-Disposition: form-data; name="d"' + crlf + crlf + + d + crlf ) if len(d) else b'') + - b'--b--' + crlf) + b'--b--' + crlf) - df = open('data.dump.dbg', mode='wb') - df.write(mime) - df.close() + #df = open('data.dump.dbg', mode='wb') + #df.write(mime) + #df.close() + # POST -use -c 'multipart/form-data; boundary="b"' http://localhost:8099/