chiark / gitweb /
fixes
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 1 Apr 2017 12:07:35 +0000 (13:07 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 1 Apr 2017 12:07:35 +0000 (13:07 +0100)
client
server

diff --git a/client b/client
index ce5e856..436592e 100755 (executable)
--- a/client
+++ b/client
@@ -102,16 +102,23 @@ def check_outbound():
                   c.max_batch_up)
     
     crlf = b'\r\n'
+    lf   =   b'\n'
     mime = (b'--b'                                      + crlf +
-            b'Content-Disposition: form-data; name="m"' + crlf +
-            password                                    + crlf +
-            str(c.client)             .encode('ascii')  + 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 +
+          ((
             b'--b'                                      + crlf +
-            b'Content-Disposition: form-data; name="d"' + crlf +
-            mime_translate(d)                           + crlf +
+            b'Content-Disposition: form-data; name="d"' + crlf + crlf +
+            mime_translate(d)                           + crlf
+           ) if len(d) else b'')                               +
             b'--b--'                                    + crlf)
 
+    df = open('data.dump.dbg', mode='wb')
+    df.write(mime)
+    df.close()
+
     log_debug(DBG.HTTP_FULL, 'requesting: ' + str(mime))
 
     hh = { 'User-Agent': ['hippotat'],
diff --git a/server b/server
index 029d064..1f65255 100755 (executable)
--- a/server
+++ b/server
@@ -174,11 +174,11 @@ class IphttpResource(twisted.web.resource.Resource):
     desca = {'d': None}
     try: process_request(request, desca)
     except Exception as e:
-      emsg = str(e).encode('utf-8')
+      emsg = repr(e)
       log_http(desca, 'EXCEPTION ' + emsg)
       request.setHeader('Content-Type','text/plain; charset="utf-8"')
       request.setResponseCode(400)
-      return emsg
+      return emsg.encode('utf-8')
     log_http(desca, '... [%s]' % id(request))
     return NOT_DONE_YET