chiark / gitweb /
wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 1 Apr 2017 20:40:42 +0000 (21:40 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 1 Apr 2017 20:40:42 +0000 (21:40 +0100)
client

diff --git a/client b/client
index cda0ac8..9ed719e 100755 (executable)
--- a/client
+++ b/client
@@ -79,12 +79,13 @@ class ResponseConsumer(twisted.internet.protocol.Protocol):
 
   def connectionLost(self, reason):
     self._log(DBG.HTTP_CTRL, 'connectionLost ' + str(reason))
-    if reason.check(twisted.web.client.ResponseDone):
-      try: self._ssd.flush()
-      except Exception as e:
-        self._asyncfailure(e)
-    else:
+    if not reason.check(twisted.web.client.ResponseDone):
       self._asyncfailure(reason)
+      return
+    try:
+      self._ssd.flush()
+    except Exception as e:
+      self._asyncfailure(e)
 
   def _asyncfailure(self, reason):
     self._log(DBG.HTTP_CTRL, '_asyncFailure ' + str(reason))
@@ -105,16 +106,23 @@ class ErrorResponseConsumer(twisted.internet.protocol.Protocol):
   def _log(self, dflag, msg, **kwargs):
     log_debug(dflag,'ERROR-RC '+msg, idof=self._req, **kwargs)
 
-  def connectionMade(self): self._m = ''
-  def dataReceived(self, data): self._m += data
+  def connectionMade(self):
+    self._m = b''
+
+  def dataReceived(self, data):
+    self._log(DBG.HTTP_CTRL, 'dataReceived ' + repr(data))
+    self._m += data
+
   def connectionLost(self, reason):
     try:
       mbody = self._m.decode('utf-8')
     except Exception:
       mbody = repr(self._m)
-    req_err(req,
-            "FAILED %d %s | %s | %s"
-            % (self._resp.code, self.phrase, mbody, str(reason)))
+    if not reason.check(twisted.web.client.ResponseDone):
+      mbody += ' || ' + str(reason)
+    req_err(self._req,
+            "FAILED %d %s | %s"
+            % (self._resp.code, self._phrase, mbody))
 
 def req_ok(req, resp):
   log_debug(DBG.HTTP_CTRL,