commit ba5846af10d337924b4f0ea06b5d0df0ee072465
Author: Arturo Filastò <art...@filasto.net>
Date:   Thu Feb 2 15:48:17 2017 +0000

    Feature/http request headers (#730)
    
    * Write a failing unittest demonstrating the bug
    
    * Fix bug that leads to Headers not being preserved across redirects
    
    * Fix backward compatibility with twisted < 15.0.0 when handling
      redirects
    
    * Skip the redirect test when the network is absent
    
    * Pass request headers to web_connectivity test helper
    
    * Fix backend unittest
---
 ooni/backend_client.py                     | 10 ++++++++--
 ooni/nettests/blocking/web_connectivity.py |  3 ++-
 ooni/tests/test_backend_client.py          |  4 +++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/ooni/backend_client.py b/ooni/backend_client.py
index 5298e7cf..4df5ff9c 100644
--- a/ooni/backend_client.py
+++ b/ooni/backend_client.py
@@ -267,10 +267,16 @@ class WebConnectivityClient(OONIBClient):
 
         return d
 
-    def control(self, http_request, tcp_connect):
+    def control(self, http_request, tcp_connect,
+                http_request_headers=None,
+                include_http_responses=False):
+        if http_request_headers is None:
+            http_request_headers = {}
         request = {
             'http_request': http_request,
-            'tcp_connect': tcp_connect
+            'tcp_connect': tcp_connect,
+            'http_request_headers': http_request_headers,
+            'include_http_responses': include_http_responses
         }
         return self.queryBackend('POST', '/', query=request)
 
diff --git a/ooni/nettests/blocking/web_connectivity.py 
b/ooni/nettests/blocking/web_connectivity.py
index c7e59776..e5085380 100644
--- a/ooni/nettests/blocking/web_connectivity.py
+++ b/ooni/nettests/blocking/web_connectivity.py
@@ -229,7 +229,8 @@ class WebConnectivityTest(httpt.HTTPTest, dnst.DNSTest):
         log.msg("* performing control request with backend")
         self.control = yield self.web_connectivity_client.control(
             http_request=self.input,
-            tcp_connect=sockets
+            tcp_connect=sockets,
+            http_request_headers=REQUEST_HEADERS
         )
         self.report['control'] = self.control
 
diff --git a/ooni/tests/test_backend_client.py 
b/ooni/tests/test_backend_client.py
index fab1fa21..8e479467 100644
--- a/ooni/tests/test_backend_client.py
+++ b/ooni/tests/test_backend_client.py
@@ -163,7 +163,9 @@ class TestBackendClient(ConfigTestCase):
             'POST', '/',
             query={
                 "http_request": "http://example.com/";,
-                "tcp_connect": ["127.0.0.1:8080", "127.0.0.1:8082"]
+                "tcp_connect": ["127.0.0.1:8080", "127.0.0.1:8082"],
+                "http_request_headers": {},
+                "include_http_responses": False
             })
 
 



_______________________________________________
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to