async def METHOD_NAME(tdata, mode, concurrency):
    handler_ok = asyncio.Event()
    async def handler(reader: asyncio.StreamReader, writer: asyncio.StreamWriter):
        if mode == "err":
            writer.close()
            handler_ok.set()
            return
        req = await reader.readline()
        if mode == "upstream":
            assert req == b"GET http://address:22/path HTTP/1.1\r\n"
        else:
            assert req == b"GET /path HTTP/1.1\r\n"
        req = await reader.readuntil(b"data")
        assert req == (
            b"header: qvalue\r\n"
            b"content-length: 4\r\nHost: example.mitmproxy.org\r\n\r\n"
            b"data"
        )
        writer.write(b"HTTP/1.1 204 No Content\r\n\r\n")
        await writer.drain()
        assert not await reader.read()
        handler_ok.set()
    cp = ClientPlayback()
    ps = Proxyserver()
    tls = TlsConfig()
    with taddons.context(cp, ps, tls) as tctx:
        tctx.configure(cp, client_replay_concurrency=concurrency)
        server_args = {}
        if mode == "https":
            server_args["ssl"] = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
            server_args["ssl"].load_cert_chain(
                certfile=tdata.path(
                    "mitmproxy/net/data/verificationcerts/trusted-leaf.crt"
                ),
                keyfile=tdata.path(
                    "mitmproxy/net/data/verificationcerts/trusted-leaf.key"
                ),
            )
            tctx.configure(
                tls,
                ssl_verify_upstream_trusted_ca=tdata.path(
                    "mitmproxy/net/data/verificationcerts/trusted-root.crt"
                ),
            )
        async with tcp_server(handler, **server_args) as addr:
            cp.running()
            flow = tflow.tflow(live=False)
            flow.request.content = b"data"
            if mode == "upstream":
                tctx.options.mode = [f"upstream:http://{addr[0]}:{addr[1]}"]
                flow.request.authority = f"{addr[0]}:{addr[1]}"
                flow.request.host, flow.request.port = "address", 22
            else:
                flow.request.host, flow.request.port = addr
            if mode == "https":
                flow.request.scheme = "https"
            # Used for SNI
            flow.request.host_header = "example.mitmproxy.org"
            cp.start_replay([flow])
            assert cp.count() == 1
            await asyncio.wait_for(cp.queue.join(), 5)
            await asyncio.wait_for(handler_ok.wait(), 5)
            cp.done()
            if mode != "err":
                assert flow.response.status_code == 204