chiark / gitweb /
wip
[hippotat.git] / server
diff --git a/server b/server
index 3bfbc4261affd995355ecdb2e25175522d3dcb65..8a16c34a390d6d195430f5b7f3e06163283b65ff 100755 (executable)
--- a/server
+++ b/server
@@ -12,8 +12,6 @@ from twisted.web.server import NOT_DONE_YET
 
 import syslog
 
-import traceback
-
 clients = { }
 
 #---------- "router" ----------
@@ -100,6 +98,10 @@ class Client():
     self._rq.append(request)
     self._check_outbound()
 
+  def _req_write(self, req, d):
+    self._log(DBG.HTTP, 'req_write ', idof=req, d=d)
+    req.write(d)
+
   def _check_outbound(self):
     log_debug(DBG.HTTP_CTRL, 'CHKO')
     while True:
@@ -123,7 +125,7 @@ class Client():
       self._log(DBG.HTTP_CTRL, 'CHKO processing', idof=request)
       # request, and also some non-expired packets
       self._pq.process((lambda: request.sentLength),
-                       request.write,
+                       (lambda d: self._req_write(request, d)),
                        self.max_batch_down)
 
       assert(request.sentLength)
@@ -165,6 +167,8 @@ def process_request(request, desca):
 
   log_http(desca, 'processing', idof=id(request), d=d)
 
+  d = mime_translate(d)
+
   cl.process_arriving_data(d)
   cl.new_request(request)
 
@@ -186,7 +190,7 @@ 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')
@@ -230,6 +234,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()