aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy
diff options
context:
space:
mode:
Diffstat (limited to 'libmproxy')
-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.