initial support for capturing bytes read from gateway response
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 10 Sep 2009 22:25:26 +0000 (22:25 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 10 Sep 2009 22:25:26 +0000 (22:25 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1774 9efc2488-bf62-4759-914b-345cdb29e865

src/python/osrf/gateway.py

index 11776a4..a71d02d 100644 (file)
@@ -13,6 +13,7 @@ class GatewayRequest:
         self.method = method
         self.params = params
         self.path = 'gateway'
+        self.bytes_read = 0 # for now this, this is really characters read
 
     def setPath(self, path):
         self.path = path
@@ -62,8 +63,11 @@ class JSONGatewayRequest(GatewayRequest):
         return self.getFormat()
 
     def handleResponse(self, response):
-        s = response.read()
-        obj = to_object(s)
+
+        data = response.read()
+        self.bytes_read = len(str(response.headers)) + len(data)
+        obj = to_object(data)
+
         if obj['status'] != 200:
             sys.stderr.write('JSON gateway returned status %d:\n%s\n' % (obj['status'], s))
             return None