From 66d21fa4ba7bec0be0acc2c33baf8c6217bd2b38 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 18 Sep 2015 13:51:05 +0200 Subject: trigger inline script hooks for artifical responses, fix #775 --- libmproxy/protocol/http.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'libmproxy/protocol/http.py') 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. -- cgit v1.2.3