[tor-commits] [ooni-probe/master] Start working on HTTP Requests

art at torproject.org art at torproject.org
Sat Nov 10 17:21:19 UTC 2012


commit 4a7d32225a6173d18dfa3df3b953e15841c02d62
Author: Arturo Filastò <arturo at filasto.net>
Date:   Wed Nov 7 18:00:10 2012 +0100

    Start working on HTTP Requests
---
 nettests/core/http_requests.py |   56 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/nettests/core/http_requests.py b/nettests/core/http_requests.py
new file mode 100644
index 0000000..f1a16e0
--- /dev/null
+++ b/nettests/core/http_requests.py
@@ -0,0 +1,56 @@
+# -*- encoding: utf-8 -*-
+#
+# :authors: Arturo Filastò
+# :licence: see LICENSE
+
+import random
+from ooni.templates import httpt
+
+def random_capitalization(string):
+    output = ""
+    string = string.swapcase()
+    for i in range(len(string)):
+        if random.randint(0, 1):
+            output += string[i].swapcase()
+        else:
+            output += string[i]
+    return output
+
+class HTTPRequests(httpt.HTTPTest):
+    """
+    This test is also known as Header Field manipulation. It performes HTTP
+    requests with variations in capitalization towards the backend.
+    """
+    name = "HTTPRequests"
+    author = "Arturo Filastò"
+    version = 0.1
+
+    optParameters = [['backend', 'b', None, 'URL of the backend to use for sending the requests']]
+
+    def processInputs(self):
+        if self.localOptions['backend']:
+            self.url = self.localOptions['backend']
+        else:
+            raise Exception("No backend specified")
+
+    def test_get(self):
+        return self.doRequest(self.url, "GET")
+
+    def test_get_random_capitalization(self):
+        method = random_capitalization("GET")
+        return self.doRequest(self.url, method)
+
+    def test_post(self):
+        return self.doRequest(self.url, "POST")
+
+    def test_post_random_capitalization(self):
+        method = random_capitalization("POST")
+        return self.doRequest(self.url, method)
+
+    def test_put(self):
+        return self.doRequest(self.url, "PUT")
+
+    def test_put_random_capitalization(self):
+        method = random_capitalization("PUT")
+        return self.doRequest(self.url, method)
+





More information about the tor-commits mailing list