From e67dbf61236c479acc77db1fbeb98d1c06ff9a0b Mon Sep 17 00:00:00 2001 From: Michael Frister Date: Thu, 8 Mar 2012 23:08:08 +0100 Subject: Handle Transfer-Encoding header values case insensitive According to HTTP/1.1 RFC 2616 Section 3.6. --- libmproxy/proxy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libmproxy') diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 3a7f807e..c5833d0c 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -106,7 +106,7 @@ def read_chunked(fp, limit): def read_http_body(rfile, connection, headers, all, limit): if 'transfer-encoding' in headers: - if not ",".join(headers["transfer-encoding"]) == "chunked": + if not ",".join(headers["transfer-encoding"]).lower() == "chunked": raise IOError('Invalid transfer-encoding') content = read_chunked(rfile, limit) elif "content-length" in headers: -- cgit v1.2.3 From 23f7214fc3e10d8a0cc9a61256b01fac117f77f2 Mon Sep 17 00:00:00 2001 From: Michael Frister Date: Thu, 8 Mar 2012 23:10:21 +0100 Subject: Fix SSL requests with Transfer-Encoding: chunked Add size parameter to FileLike.readline, used by read_chunked. --- libmproxy/proxy.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libmproxy') diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index c5833d0c..72a7a5a3 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -184,10 +184,14 @@ class FileLike: result += data return result - def readline(self): + def readline(self, size = None): result = '' + bytes_read = 0 while True: + if size is not None and bytes_read >= size: + break ch = self.read(1) + bytes_read += 1 if not ch: break else: -- cgit v1.2.3