Skip to content

Instantly share code, notes, and snippets.

@urbanautomaton
Last active April 9, 2018 11:40
Show Gist options
  • Save urbanautomaton/467861e3d83688d899d0bfa3dcee6f8f to your computer and use it in GitHub Desktop.
Save urbanautomaton/467861e3d83688d899d0bfa3dcee6f8f to your computer and use it in GitHub Desktop.
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