Last active
April 9, 2018 11:40
-
-
Save urbanautomaton/467861e3d83688d899d0bfa3dcee6f8f to your computer and use it in GitHub Desktop.
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 flow.request.pretty_url.startswith("https://www.example.net/exercise"): | |
flow.response = http.HTTPResponse.make( | |
200, | |
b"exercise-content", | |
) | |
elif flow.request.pretty_url.startswith("https://cdnjs.cloudflare.com/ajax/libs/mathjax"): | |
flow.response = http.HTTPResponse.make( | |
200, | |
b""" | |
window.MathJax = { | |
Hub: { | |
Queue: function() { | |
return function() { }; | |
} | |
} | |
} | |
""" | |
) | |
elif flow.request.pretty_host != "127.0.0.1": | |
flow.response = http.HTTPResponse.make(200, b"") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment