chiark / gitweb /
wip, towards target
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 1 Apr 2017 19:39:35 +0000 (20:39 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 1 Apr 2017 19:39:35 +0000 (20:39 +0100)
client

diff --git a/client b/client
index 829087e..7b2bf78 100755 (executable)
--- a/client
+++ b/client
@@ -59,7 +59,9 @@ def outbound(packet, saddr, daddr):
   check_outbound()
 
 class ResponseConsumer(twisted.internet.protocol.Protocol):
-  def __init__(self):
+  def __init__(self, req):
+    print('RC INIT', file=sys.stderr)
+    self._req = req
     self._ssd = SlipStreamDecoder(queue_inbound)
 
   def dataReceived(self, data):
@@ -73,8 +75,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):
@@ -141,7 +144,8 @@ def check_outbound():
                         twisted.web.client.Headers(hh),
                         producer)
     req.addTimeout(c.http_timeout, reactor)
-    req.addCallbacks(req_ok, req_err)
+    req.addCallback((lambda resp: req_ok(req, resp)))
+    req.addErrback(req_err)
     outstanding += 1
 
 common_startup()