Skip to content

Instantly share code, notes, and snippets.

@avernet
Created December 1, 2023 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avernet/bb071ba621798f40b3fce7c8579bf27e to your computer and use it in GitHub Desktop.
Save avernet/bb071ba621798f40b3fce7c8579bf27e to your computer and use it in GitHub Desktop.
mitmproxy: add a `My-Counter` header incremented with every request
from mitmproxy import http
class AddHeader:
def __init__(self):
self.counter = 0
def request(self, flow: http.HTTPFlow) -> None:
self.counter += 1
flow.request.headers["My-Counter"] = str(self.counter)
addons = [
AddHeader()
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment