commit 8e8f3502944295b019f919e703c2f1396153b45e Author: Arturo Filastò arturo@filasto.net Date: Fri Sep 28 14:14:41 2012 +0000
Add an example of using the HTTP test template. --- nettests/example_http.py | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/nettests/example_http.py b/nettests/example_http.py new file mode 100644 index 0000000..7528d48 --- /dev/null +++ b/nettests/example_http.py @@ -0,0 +1,28 @@ +# -*- encoding: utf-8 -*- +# +# :authors: Arturo Filastò +# :licence: see LICENSE + +from ooni.templates import http +class Example(http.HTTPTest): + inputs = ['http://google.com/', 'http://wikileaks.org/', + 'http://torproject.org/'] + + def processResponseBody(self, body): + # XXX here shall go your logic + # for processing the body + if 'blocked' in body: + self.report['censored'] = True + else: + self.report['censored'] = False + + def processResponseHeaders(self, headers): + # XXX place in here all the logic for handling the processing of HTTP + # Headers. + if headers.hasHeader('location'): + self.report['redirect'] = True + + server = headers.getRawHeaders("Server") + if server: + self.report['http_server'] = str(server.pop()) +