aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/protocol/http.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-09-18 13:51:05 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-09-18 13:51:05 +0200
commit66d21fa4ba7bec0be0acc2c33baf8c6217bd2b38 (patch)
treed311b105aecd3fb3c7b7cf7b5b2eff1321820d68 /libmproxy/protocol/http.py
parent5df5ee15f22284ef6ab9fcfc5c2b605c23c8fdc8 (diff)
downloadmitmproxy-66d21fa4ba7bec0be0acc2c33baf8c6217bd2b38.tar.gz
mitmproxy-66d21fa4ba7bec0be0acc2c33baf8c6217bd2b38.tar.bz2
mitmproxy-66d21fa4ba7bec0be0acc2c33baf8c6217bd2b38.zip
trigger inline script hooks for artifical responses, fix #775
Diffstat (limited to 'libmproxy/protocol/http.py')
-rw-r--r--libmproxy/protocol/http.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py
index a1b2605f..21c2a72c 100644
--- a/libmproxy/protocol/http.py
+++ b/libmproxy/protocol/http.py
@@ -330,7 +330,17 @@ class HttpLayer(Layer):
if not flow.response:
self.establish_server_connection(flow)
self.get_response_from_server(flow)
-
+ else:
+ # response was set by an inline script.
+ # we now need to emulate the responseheaders hook.
+ flow = self.channel.ask("responseheaders", flow)
+ if flow == Kill:
+ raise Kill()
+
+ self.log("response", "debug", [repr(flow.response)])
+ flow = self.channel.ask("response", flow)
+ if flow == Kill:
+ raise Kill()
self.send_response_to_client(flow)
if self.check_close_connection(flow):
@@ -454,15 +464,6 @@ class HttpLayer(Layer):
# we can safely set it as the final attribute value here.
flow.server_conn = self.server_conn
- self.log(
- "response",
- "debug",
- [repr(flow.response)]
- )
- response_reply = self.channel.ask("response", flow)
- if response_reply == Kill:
- raise Kill()
-
def process_request_hook(self, flow):
# Determine .scheme, .host and .port attributes for inline scripts.
# For absolute-form requests, they are directly given in the request.