[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Log to error log file when we get malformed Headers sent to the backend
commit 27286ce77673ae99b7e7acc52e42e39fdb97b240
Author: Arturo Filastò <art@xxxxxxxxx>
Date: Thu Nov 29 17:51:11 2012 +0100
Log to error log file when we get malformed Headers sent to the backend
* Python's typesafe, but it's still good practice
---
oonib/testhelpers/http_helpers.py | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/oonib/testhelpers/http_helpers.py b/oonib/testhelpers/http_helpers.py
index 1fa0ccb..6415291 100644
--- a/oonib/testhelpers/http_helpers.py
+++ b/oonib/testhelpers/http_helpers.py
@@ -71,8 +71,12 @@ class SimpleHTTPChannel(basic.LineReceiver, policies.TimeoutMixin):
self.__header = line
def headerReceived(self, line):
- header, data = line.split(':', 1)
- self.headers.append((header, data.strip()))
+ try:
+ header, data = line.split(':', 1)
+ self.headers.append((header, data.strip()))
+ except:
+ log.err("Got malformed HTTP Header request field")
+ log.err("%s" % line)
def allHeadersReceived(self):
headers_dict = {}
@@ -85,8 +89,9 @@ class SimpleHTTPChannel(basic.LineReceiver, policies.TimeoutMixin):
'request_line': self.requestLine,
'headers_dict': headers_dict
}
+ json_response = json.dumps(response)
self.transport.write('HTTP/1.1 200 OK\r\n\r\n')
- self.transport.write(json.dumps(response))
+ self.transport.write('%s' % json_response)
self.transport.loseConnection()
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits