Created
December 20, 2021 17:42
-
-
Save edgesider/6d92172d5cc98f660e71e3e73018dafe to your computer and use it in GitHub Desktop.
mitmproxy asyncio request
This file contains hidden or 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 | |
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