예제 #1
0
        public override async Task Initialize(TestContext ctx, HttpOperation operation, CancellationToken cancellationToken)
        {
            remoteEndPoint = (IPEndPoint)Socket.RemoteEndPoint;
            ctx.LogDebug(5, $"{ME} INITIALIZE: {ListenSocket?.LocalEndPoint} {remoteEndPoint} {operation?.ME}");
            if (operation != null)
            {
                networkStream = operation.CreateNetworkStream(ctx, Socket, true);
            }
            if (networkStream == null)
            {
                networkStream = new NetworkStream(Socket, true);
            }

            if (Server.SslStreamProvider != null)
            {
                sslStream = await CreateSslStream(ctx, networkStream, cancellationToken).ConfigureAwait(false);

                Stream = sslStream;
            }
            else
            {
                Stream = networkStream;
            }

            reader = new HttpStreamReader(Stream);
            ctx.LogDebug(5, $"{ME} INITIALIZE DONE: {ListenSocket?.LocalEndPoint} {remoteEndPoint}");
        }