()
| 32 | |
| 33 | |
| 34 | async def make_request(): |
| 35 | try: |
| 36 | cafile = Path(ctx.options.confdir).expanduser() / "mitmproxy-ca.pem" |
| 37 | while not cafile.exists(): |
| 38 | await asyncio.sleep(0.01) |
| 39 | ssl_ctx = ssl.create_default_context(cafile=cafile) |
| 40 | port = ctx.master.addons.get("proxyserver").listen_addrs()[0][1] |
| 41 | reader, writer = await asyncio.open_connection("127.0.0.1", port, ssl=ssl_ctx) |
| 42 | writer.write(b"GET / HTTP/1.1\r\nHost: mitm.it\r\nConnection: close\r\n\r\n") |
| 43 | await writer.drain() |
| 44 | resp = await reader.read() |
| 45 | if b"This page is served by your local mitmproxy instance" not in resp: |
| 46 | raise RuntimeError(resp) |
| 47 | logging.info("Self-test successful.") |
| 48 | ctx.master.shutdown() |
| 49 | except Exception as e: |
| 50 | print(f"{e!r}") |
| 51 | sys.exit(1) |
no test coverage detected
searching dependent graphs…