MCPcopy
hub / github.com/mitmproxy/mitmproxy / make_request

Function make_request

release/selftest.py:34–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32
33
34async 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)

Callers 1

runningFunction · 0.85

Calls 9

PathClass · 0.85
open_connectionMethod · 0.80
infoMethod · 0.80
exitMethod · 0.80
listen_addrsMethod · 0.45
getMethod · 0.45
writeMethod · 0.45
readMethod · 0.45
shutdownMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…