From f89a5235d36db8c82ec608ba1f39809d2a355384 Mon Sep 17 00:00:00 2001 From: Marcelo Glezer Date: Wed, 14 Jan 2015 10:52:52 -0300 Subject: wip - content copy is working, header representation is not --- libmproxy/protocol/http.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libmproxy/protocol/http.py') diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index bebb4f7b..04e3fe40 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -953,6 +953,21 @@ class HTTPFlow(Flow): c += self.response.replace(pattern, repl, *args, **kwargs) return c + def response_content(self): + s = "[No Content]" + with decoded(self.response): + s = self.response.content + return s + + def response_headers(self): + with decoded(self.response): + sh = "" + for i in self.flow.response.headers: + v = self.flow.response.headers[i] + for j in v: + sh += str(i)+"="+str(v[j])+"\n" + return sh + class HttpAuthenticationError(Exception): def __init__(self, auth_headers=None): -- cgit v1.2.3 From ee75a0b9cbe5f4882453d2f1cb0d0a7df431200a Mon Sep 17 00:00:00 2001 From: Marcelo Glezer Date: Wed, 14 Jan 2015 12:03:40 -0300 Subject: now content and header are working and exception for binary files are handled correctly --- libmproxy/protocol/http.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'libmproxy/protocol/http.py') diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index 04e3fe40..63f9e47b 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -954,20 +954,18 @@ class HTTPFlow(Flow): return c def response_content(self): - s = "[No Content]" with decoded(self.response): s = self.response.content + if s == None: + s = "[No content]" return s def response_headers(self): with decoded(self.response): - sh = "" - for i in self.flow.response.headers: - v = self.flow.response.headers[i] - for j in v: - sh += str(i)+"="+str(v[j])+"\n" - return sh - + s = str(self.response.headers) + if s == None: + s = "[]" + return s class HttpAuthenticationError(Exception): def __init__(self, auth_headers=None): -- cgit v1.2.3 From fdd012bdd80b0a1419e8967f10c92a9384a72da5 Mon Sep 17 00:00:00 2001 From: Marcelo Glezer Date: Wed, 14 Jan 2015 12:09:14 -0300 Subject: removed invalid comment and unneeded safe text --- libmproxy/protocol/http.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'libmproxy/protocol/http.py') diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index 63f9e47b..f59b76ad 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -956,15 +956,11 @@ class HTTPFlow(Flow): def response_content(self): with decoded(self.response): s = self.response.content - if s == None: - s = "[No content]" return s def response_headers(self): with decoded(self.response): s = str(self.response.headers) - if s == None: - s = "[]" return s class HttpAuthenticationError(Exception): -- cgit v1.2.3 From d9f562b5c0ba0b4769455c117c1321d63ff6497c Mon Sep 17 00:00:00 2001 From: Marcelo Glezer Date: Wed, 14 Jan 2015 14:45:19 -0300 Subject: used get_decoded_content and removed decode call from headers as max suggested --- libmproxy/protocol/http.py | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'libmproxy/protocol/http.py') diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index f59b76ad..284731b0 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -953,16 +953,6 @@ class HTTPFlow(Flow): c += self.response.replace(pattern, repl, *args, **kwargs) return c - def response_content(self): - with decoded(self.response): - s = self.response.content - return s - - def response_headers(self): - with decoded(self.response): - s = str(self.response.headers) - return s - class HttpAuthenticationError(Exception): def __init__(self, auth_headers=None): super(HttpAuthenticationError, self).__init__( -- cgit v1.2.3 From 102183fd23afceda84ca79bcc67305cf9f4e8369 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Sat, 7 Feb 2015 00:36:47 +0100 Subject: remove leftovers --- libmproxy/protocol/http.py | 1 + 1 file changed, 1 insertion(+) (limited to 'libmproxy/protocol/http.py') diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index 284731b0..bebb4f7b 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -953,6 +953,7 @@ class HTTPFlow(Flow): c += self.response.replace(pattern, repl, *args, **kwargs) return c + class HttpAuthenticationError(Exception): def __init__(self, auth_headers=None): super(HttpAuthenticationError, self).__init__( -- cgit v1.2.3 From 1df78f75c5ceb368ca9ba9d1b01e17af21cab892 Mon Sep 17 00:00:00 2001 From: Marcelo Glezer Date: Tue, 10 Feb 2015 17:18:23 -0300 Subject: set sni to None when no server_conn is None --- libmproxy/protocol/http.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libmproxy/protocol/http.py') diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index 2f858a7c..79a4bf74 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -1457,9 +1457,11 @@ class RequestReplayThread(threading.Thread): server = ServerConnection(server_address) server.connect() if r.scheme == "https": - server.establish_ssl(self.config.clientcerts, sni=self.flow.server_conn.sni) + sni = None + if self.flow.server_conn: + sni = self.flow.server_conn.sni + server.establish_ssl(self.config.clientcerts, sni=sni) r.form_out = "relative" - server.send(r.assemble()) self.flow.server_conn = server self.flow.response = HTTPResponse.from_stream(server.rfile, r.method, -- cgit v1.2.3 From 010b921a93b2c7e3d6b26ca0db4538a56d7c8fb0 Mon Sep 17 00:00:00 2001 From: Marcelo Glezer Date: Thu, 12 Feb 2015 13:41:58 -0300 Subject: added sni and ssl_established=true in ServerConnection. removed check for None value of server_conn in http.py --- libmproxy/protocol/http.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'libmproxy/protocol/http.py') diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index 79a4bf74..046d0b42 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -1457,10 +1457,7 @@ class RequestReplayThread(threading.Thread): server = ServerConnection(server_address) server.connect() if r.scheme == "https": - sni = None - if self.flow.server_conn: - sni = self.flow.server_conn.sni - server.establish_ssl(self.config.clientcerts, sni=sni) + server.establish_ssl(self.config.clientcerts, sni=self.flow.server_conn.sni) r.form_out = "relative" server.send(r.assemble()) self.flow.server_conn = server -- cgit v1.2.3