[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Fix the unittests for the oonibclient.
commit 565e6ddd4fed36fce77d4c8d1c94190c9db6b1de
Author: Arturo Filastò <art@xxxxxxxxx>
Date: Tue Jan 28 15:43:53 2014 +0100
Fix the unittests for the oonibclient.
---
ooni/oonibclient.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/ooni/oonibclient.py b/ooni/oonibclient.py
index 1fa2e5b..e257ef8 100644
--- a/ooni/oonibclient.py
+++ b/ooni/oonibclient.py
@@ -3,6 +3,7 @@ import json
from hashlib import sha256
+from twisted.web.client import Agent
from twisted.internet import defer, reactor
from twisted.internet.endpoints import TCP4ClientEndpoint
@@ -54,6 +55,10 @@ class OONIBClient(object):
elif address.startswith('https://'):
log.err("HTTPS based bouncers are currently not supported.")
+ elif address.startswith('http://'):
+ log.msg("Warning using unencrypted collector")
+ self.address = address
+ self.agent = Agent(reactor)
def _request(self, method, urn, genReceiver, bodyProducer=None):
attempts = 0
@@ -67,7 +72,10 @@ class OONIBClient(object):
@d.addCallback
def callback(response):
- content_length = int(response.headers.getRawHeaders('content-length')[0])
+ try:
+ content_length = int(response.headers.getRawHeaders('content-length')[0])
+ except:
+ content_length = None
response.deliverBody(genReceiver(finished, content_length))
def errback(err, attempts):
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits