[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Use inlineCallbacks
commit e59174fe7d37840eec745bb851ec844e1948ab34
Author: aagbsn <aagbsn@xxxxxxxx>
Date: Wed Sep 18 20:46:59 2013 +0200
Use inlineCallbacks
For some reason, using inlineCallbacks seems to produce a proper result
from the doRequest method -- however, in the previous code the returned
deferred had been called but the result was not set.
---
ooni/nettests/blocking/http_requests.py | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/ooni/nettests/blocking/http_requests.py b/ooni/nettests/blocking/http_requests.py
index 48f8f94..20fae42 100644
--- a/ooni/nettests/blocking/http_requests.py
+++ b/ooni/nettests/blocking/http_requests.py
@@ -91,27 +91,27 @@ class HTTPRequestsTest(httpt.HTTPTest):
self.report['headers_diff'] = diff
self.report['headers_match'] = True
+ @defer.inlineCallbacks
def test_get_experiment(self):
log.msg("Performing GET request to %s" % self.url)
- self.experiment = self.doRequest(self.url, method="GET",
+ self.experiment = yield self.doRequest(self.url, method="GET",
use_tor=False, headers=self.headers)
- return self.experiment
+ @defer.inlineCallbacks
def test_get_control(self):
log.msg("Performing GET request to %s over Tor" % self.url)
- self.control = self.doRequest(self.url, method="GET",
+ self.control = yield self.doRequest(self.url, method="GET",
use_tor=True, headers=self.headers)
- return self.control
def postProcessor(self, measurements):
- if self.experiment.result and self.control.result:
- self.compare_body_lengths(len(self.control.result.body),
- len(self.experiment.result.body))
- self.compare_headers(self.control.result.headers,
- self.experiment.result.headers)
-
- if not self.control.result:
- self.report['control_failure'] = failureToString(self.control.result)
- if not self.experiment.result:
- self.report['experiment_failure'] = failureToString(self.experiment.result)
+ if self.experiment and self.control:
+ self.compare_body_lengths(len(self.control.body),
+ len(self.experiment.body))
+ self.compare_headers(self.control.headers,
+ self.experiment.headers)
+
+ if not self.control:
+ self.report['control_failure'] = failureToString(self.control)
+ if not self.experiment:
+ self.report['experiment_failure'] = failureToString(self.experiment)
return self.report
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits