X-Git-Url: https://git.distorted.org.uk/~mdw/hippotat/blobdiff_plain/fc0ba433402d7103b351d7742aa20ff62800a0dd..6f387df3234541f1066eff163d18fa6becf59c82:/server diff --git a/server b/server index 79bd15b..e5aa67b 100755 --- a/server +++ b/server @@ -139,7 +139,7 @@ class Client(): def process_request(request, desca): # find client, update config, etc. - metadata = request.args[b'mX'][0] + metadata = request.args[b'm'][0] metadata = metadata.split(b'\r\n') (ci_s, pw, tro) = metadata[0:3] desca['m[0,2]'] = [ci_s, tro] @@ -158,18 +158,25 @@ def process_request(request, desca): try: d = request.args[b'd'][0] desca['d'] = d - except KeyError: d = b'' + desca['dlen'] = len(d) + except KeyError: + d = b'' + desca['dlen'] = None + + log_http(desca, 'processing', idof=id(request), d=d) + + d = mime_translate(d) cl.process_arriving_data(d) cl.new_request(request) -def log_http(desca, msg): +def log_http(desca, msg, **kwargs): try: - d = desca['d'] + kwargs['d'] = desca['d'] del desca['d'] except KeyError: - d = None - log_debug(DBG.HTTP, msg + repr(desca), d=d) + pass + log_debug(DBG.HTTP, msg + repr(desca), **kwargs) class IphttpResource(twisted.web.resource.Resource): isLeaf = True @@ -181,11 +188,11 @@ class IphttpResource(twisted.web.resource.Resource): try: process_request(request, desca) except Exception as e: emsg = traceback.format_exc() - log_http(desca, 'EXCEPTION ' + emsg) + log_http(desca, 'RETURNING EXCEPTION ' + emsg) request.setHeader('Content-Type','text/plain; charset="utf-8"') request.setResponseCode(400) return (emsg + ' # ' + repr(desca) + '\r\n').encode('utf-8') - log_http(desca, '... [%s]' % id(request)) + log_debug(DBG.HTTP_CTRL, '...', idof=id(request)) return NOT_DONE_YET def render_GET(self, request): @@ -225,6 +232,6 @@ def process_cfg(): common_startup() process_cfg() -start_ipif(c.ipif_command, route) +start_ipif(c.ipif_command, (lambda p,s,d: route(p,"[ipif]",s,d))) start_http() common_run()