[tor-commits] [ooni-probe/master] Patch twisted HTTPClientParser to accept HTTP response lines with a missing reason
art at torproject.org
art at torproject.org
Mon May 30 16:28:33 UTC 2016
commit c50f50cb0984cefabc82bd4f559062dbc893736c
Author: Arturo Filastò <arturo at filasto.net>
Date: Sun May 8 19:09:46 2016 +0200
Patch twisted HTTPClientParser to accept HTTP response lines with a missing reason
---
ooni/utils/trueheaders.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/ooni/utils/trueheaders.py b/ooni/utils/trueheaders.py
index a5b2fe3..5f2b399 100644
--- a/ooni/utils/trueheaders.py
+++ b/ooni/utils/trueheaders.py
@@ -115,6 +115,26 @@ class HTTPClientParser(_newclient.HTTPClientParser):
headers.addRawHeader(name, value)
+ def statusReceived(self, status):
+ parts = status.split(b' ', 2)
+ if len(parts) != 3:
+ # Here we add the extra missing part.
+ parts.append("XXX")
+
+ try:
+ statusCode = int(parts[1])
+ except ValueError:
+ raise _newclient.ParseError(u"non-integer status code", status)
+
+ self.response = _newclient.Response._construct(
+ self.parseVersion(parts[0]),
+ statusCode,
+ parts[2],
+ self.headers,
+ self.transport,
+ self.request)
+
+
class HTTP11ClientProtocol(_newclient.HTTP11ClientProtocol):
def request(self, request):
if self._state != 'QUIESCENT':
More information about the tor-commits
mailing list