[tor-commits] [ooni-probe/master] Make the user agent selection in the HTTP Requests test be static

art at torproject.org art at torproject.org
Tue Feb 26 15:52:41 UTC 2013


commit 185867db9f33446d6c6f0e2cc3acffa4a4a1f7d4
Author: Arturo Filastò <art at fuffa.org>
Date:   Fri Feb 8 22:43:29 2013 +0100

    Make the user agent selection in the HTTP Requests test be static
    
    This is to avoid false positives due to user agent based targeted content
---
 nettests/blocking/http_requests.py |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/nettests/blocking/http_requests.py b/nettests/blocking/http_requests.py
index ef2cece..4d99fc3 100644
--- a/nettests/blocking/http_requests.py
+++ b/nettests/blocking/http_requests.py
@@ -3,10 +3,12 @@
 # :authors: Arturo Filastò
 # :licence: see LICENSE
 
+import random
 from twisted.internet import defer
 from twisted.python import usage
 
 from ooni.utils import log
+from ooni.utils.net import userAgents
 from ooni.templates import httpt
 from ooni.nettest import failureToString, handleAllFailures
 
@@ -27,11 +29,11 @@ class HTTPRequestsTest(httpt.HTTPTest):
     """
     name = "HTTP Requests Test"
     author = "Arturo Filastò"
-    version = "0.2.2"
+    version = "0.2.3"
 
     usageOptions = UsageOptions
 
-    inputFile = ['file', 'f', None, 
+    inputFile = ['file', 'f', None,
             'List of URLS to perform GET and POST requests to']
 
     # These values are used for determining censorship based on response body
@@ -107,13 +109,16 @@ class HTTPRequestsTest(httpt.HTTPTest):
             if not experiment_succeeded:
                 self.report['experiment_failure'] = failureToString(experiment_result)
 
+        headers = {'User-Agent': [random.choice(userAgents)]}
+
         l = []
         log.msg("Performing GET request to %s" % self.url)
-        experiment_request = self.doRequest(self.url, method="GET")
+        experiment_request = self.doRequest(self.url, method="GET",
+                headers=headers)
 
         log.msg("Performing GET request to %s via Tor" % self.url)
         control_request = self.doRequest(self.url, method="GET",
-                use_tor=True)
+                use_tor=True, headers=headers)
 
         l.append(experiment_request)
         l.append(control_request)





More information about the tor-commits mailing list