public HttpInstrumentationContent(HttpInstrumentationTestRunner runner, HttpInstrumentationRequest request)
            {
                TestRunner = runner;
                Request    = request;
                ME         = $"{GetType ().Name}({runner.EffectiveType})";

                switch (runner.EffectiveType)
                {
                case HttpInstrumentationTestType.NtlmWhileQueued2:
                    HasLength = true;
                    Length    = ((HelloWorldHandler)request.Handler.Target).Message.Length;
                    break;

                default:
                    HasLength = true;
                    Length    = 4096;
                    break;
                }
            }
        public HttpInstrumentationHandler(HttpInstrumentationTestRunner parent, bool primary)
            : base(parent, parent.EffectiveType.ToString())
        {
            readyTcs = new TaskCompletionSource <bool> ();
            Flags    = RequestFlags.KeepAlive;

            switch (parent.EffectiveType)
            {
            case HttpInstrumentationTestType.ReuseConnection:
                CloseConnection = !primary;
                break;

            case HttpInstrumentationTestType.ReuseAfterPartialRead:
                Content         = ConnectionHandler.GetLargeStringContent(2500);
                OperationFlags  = HttpOperationFlags.ClientUsesNewConnection;
                CloseConnection = !primary;
                break;

            case HttpInstrumentationTestType.ReuseConnection2:
                Content         = HttpContent.HelloWorld;
                CloseConnection = !primary;
                break;

            case HttpInstrumentationTestType.CloseIdleConnection:
            case HttpInstrumentationTestType.CloseCustomConnectionGroup:
                CloseConnection = false;
                break;

            case HttpInstrumentationTestType.NtlmClosesConnection:
                AuthManager     = parent.GetAuthenticationManager();
                CloseConnection = true;
                break;

            case HttpInstrumentationTestType.NtlmReusesConnection:
                AuthManager     = parent.GetAuthenticationManager();
                CloseConnection = false;
                break;

            case HttpInstrumentationTestType.ParallelNtlm:
            case HttpInstrumentationTestType.NtlmInstrumentation:
            case HttpInstrumentationTestType.NtlmWhileQueued:
            case HttpInstrumentationTestType.NtlmWhileQueued2:
                AuthManager     = parent.GetAuthenticationManager();
                CloseConnection = false;
                break;

            case HttpInstrumentationTestType.CustomConnectionGroup:
                OperationFlags  = HttpOperationFlags.DontReuseConnection | HttpOperationFlags.ForceNewConnection;
                CloseConnection = !primary;
                break;

            case HttpInstrumentationTestType.ReuseCustomConnectionGroup:
            case HttpInstrumentationTestType.AbortResponse:
                CloseConnection = !primary;
                break;

            case HttpInstrumentationTestType.RedirectOnSameConnection:
                Target          = new HelloWorldHandler(ME);
                CloseConnection = false;
                break;

            default:
                throw new NotSupportedException(parent.EffectiveType.ToString());
            }

            if (CloseConnection)
            {
                Flags |= RequestFlags.CloseConnection;
            }

            if (AuthManager != null)
            {
                Target = new HelloWorldHandler(ME);
            }

            if (ExpectedContent == null)
            {
                ExpectedContent = Content ?? new StringContent(ME);
            }
        }