Created
July 2, 2018 08:55
-
-
Save grunka/c2dcaae203cf187b6b1ede1ffc07d073 to your computer and use it in GitHub Desktop.
mitmproxy script for replacing a specific url with the content from a local file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mitmproxy import http | |
def request(flow: http.HTTPFlow) -> None: | |
if "example.com/path/file.html" in flow.request.pretty_url: | |
with open('replacement.html', 'r') as myfile: | |
html = myfile.read().replace('\n', '') | |
flow.response = http.HTTPResponse.make( | |
200, # status code | |
html, # content | |
{"Content-Type": "text/html"} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment