commit 51caef2bf217216b9330d1f4b449b59cf869c9f0 Author: Arturo Filastò art@fuffa.org Date: Wed Aug 21 14:55:05 2013 +0200
Add support for running body_processor --- ooni/utils/net.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/ooni/utils/net.py b/ooni/utils/net.py index e97d8c3..b63a173 100644 --- a/ooni/utils/net.py +++ b/ooni/utils/net.py @@ -62,10 +62,11 @@ class StringProducer(object): pass
class BodyReceiver(protocol.Protocol): - def __init__(self, finished, content_length=None): + def __init__(self, finished, content_length=None, body_processor=None): self.finished = finished self.data = "" self.bytes_remaining = content_length + self.body_processor = body_processor
def dataReceived(self, b): self.data += b @@ -76,6 +77,8 @@ class BodyReceiver(protocol.Protocol): self.bytes_remaining -= len(b)
def connectionLost(self, reason): + if self.body_processor: + self.data = self.body_processor(self.data) self.finished.callback(self.data)
def getSystemResolver():
tor-commits@lists.torproject.org