mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
trigger inline script hooks for artifical responses, fix #775
This commit is contained in:
parent
5df5ee15f2
commit
66d21fa4ba
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user