Skip to content

Instantly share code, notes, and snippets.

@edgesider
Created December 20, 2021 17:42
Show Gist options
  • Save edgesider/6d92172d5cc98f660e71e3e73018dafe to your computer and use it in GitHub Desktop.
Save edgesider/6d92172d5cc98f660e71e3e73018dafe to your computer and use it in GitHub Desktop.
mitmproxy asyncio request
from mitmproxy import http
import asyncio
def request(flow: http.HTTPFlow):
flow.intercept()
async def resume():
try:
await async_request(flow)
except Exception as e:
flow.response = http.Response.make(500, f'mitmproxy intercept error: {e}\n')
flow.resume()
asyncio.create_task(resume())
async def async_request(flow: http.HTTPFlow):
await asyncio.sleep(3)
print(flow.request.query)
flow.request.query['async'] = ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment