Beispiel #1
0
        protected Request CreateRequest(TestContext ctx, Uri uri)
        {
            ctx.LogDebug(LogCategories.Https, 1, "Create request: {0}", uri);
            var webRequest = Provider.Client.SslStreamProvider.CreateWebRequest(uri, Parameters);

            var request = new TraditionalRequest(webRequest);

            if (false && Parameters.Type == HttpValidationTestType.MartinTest)
            {
                request.RequestExt.Timeout = 1500;
            }

            if (Parameters.SendChunked)
            {
                request.RequestExt.SetSendChunked(true);
            }

            if (Parameters.OverrideTargetHost != null)
            {
                request.RequestExt.Host = Parameters.OverrideTargetHost;
            }

            request.RequestExt.SetKeepAlive(true);

            if (Parameters.ClientCertificateValidator != null)
            {
                request.RequestExt.InstallCertificateValidator(Parameters.ClientCertificateValidator.ValidationCallback);
            }

            if (Parameters.ClientCertificate != null)
            {
                var certificates = new X509CertificateCollection();
                certificates.Add(Parameters.ClientCertificate);
                request.RequestExt.SetClientCertificates(certificates);
            }

            if (ExternalServer)
            {
                var servicePoint = ServicePointManager.FindServicePoint(Parameters.ExternalServer);
                if (servicePoint != null)
                {
                    servicePoint.CloseConnectionGroup(null);
                }
            }

            return(request);
        }
Beispiel #2
0
        public async Task RunPuppy(TestContext ctx, HttpServer server,
                                   [Fork(5, RandomDelay = 1500)] IFork fork, [Repeat(50)] int repeat,
                                   [ForkHandler] Handler handler, CancellationToken cancellationToken)
        {
            var support = DependencyInjector.Get <IPortableSupport> ();

            ctx.LogMessage("FORK START: {0} {1}", fork.ID, support.CurrentThreadId);

            var uri = new Uri(PostPuppy);

            var request = new TraditionalRequest(uri);

            handler.ConfigureRequest(ctx, request, request.Request.RequestUri);

            var response = await request.Send(ctx, cancellationToken);

            bool ok;

            if (response.Error != null)
            {
                if (response.Content != null)
                {
                    ctx.OnError(new WebException(response.Content.AsString(), response.Error));
                }
                else
                {
                    ctx.OnError(response.Error);
                }
                ok = false;
            }
            else
            {
                ok = ctx.Expect(HttpStatusCode.OK, Is.EqualTo(response.Status), "status code");
                if (ok)
                {
                    ok &= ctx.Expect(response.IsSuccess, Is.True, "success status");
                }
            }

            ctx.LogMessage("FORK DONE: {0} {1} {2}", fork.ID, support.CurrentThreadId, ok);
        }
Beispiel #3
0
        protected Request CreateRequest(TestContext ctx, Uri uri)
        {
            ctx.LogMessage("Create request: {0}", uri);
            var webRequest = Provider.Client.SslStreamProvider.CreateWebRequest(uri, Parameters);

            var request = new TraditionalRequest(webRequest);

            if (Parameters.OverrideTargetHost != null)
            {
                request.RequestExt.Host = Parameters.OverrideTargetHost;
            }

            request.RequestExt.SetKeepAlive(true);

            if (Parameters.ClientCertificateValidator != null)
            {
                request.RequestExt.InstallCertificateValidator(Parameters.ClientCertificateValidator.ValidationCallback);
            }

            if (Parameters.ClientCertificate != null)
            {
                var certificates = new X509CertificateCollection();
                certificates.Add(Parameters.ClientCertificate);
                request.RequestExt.SetClientCertificates(certificates);
            }

            if (ExternalServer)
            {
                var servicePoint = ServicePointManager.FindServicePoint(Parameters.ExternalServer);
                if (servicePoint != null)
                {
                    servicePoint.CloseConnectionGroup(null);
                }
            }

            return(request);
        }