public static HttpWebRequest CreateThaliWebRequest(HttpKeyUri httpKeyUri, X509Certificate2 clientCertificate)
        {
            Debug.Assert(httpKeyUri != null && clientCertificate != null);
            var expectedServerRsaKey = httpKeyUri.ServerPublicKey;
            var httpWebRequest = WebRequest.CreateHttp(httpKeyUri.CreateHttpsUrl());
            httpWebRequest.ServerCertificateValidationCallback =
                ServerCertificateValidationCallbackGenerator(expectedServerRsaKey);
            httpWebRequest.ClientCertificates.Add(clientCertificate);

            // There is a bug in TJWS that doesn't handle Expect 100 Continue correctly
            httpWebRequest.ServicePoint.Expect100Continue = false;

            // This is a desperate bid to see if our perf issues are because we are recycling TCP connections too quickly, I tend to doubt it.
            httpWebRequest.ServicePoint.SetTcpKeepAlive(true, 1000, 10 * 1000);

            // Nagle combines small packets into big packets which is very good on long haul connections but we are only talking locally
            httpWebRequest.ServicePoint.UseNagleAlgorithm = false;

            // Since most of our requests are anyway serially I doubt this will help but I'm desperate so let's try.
            httpWebRequest.ServicePoint.ConnectionLimit = 100;

            return httpWebRequest;
        }
Esempio n. 2
0
        public static HttpWebRequest CreateThaliWebRequest(HttpKeyUri httpKeyUri, X509Certificate2 clientCertificate)
        {
            Debug.Assert(httpKeyUri != null && clientCertificate != null);
            var expectedServerRsaKey = httpKeyUri.ServerPublicKey;
            var httpWebRequest       = WebRequest.CreateHttp(httpKeyUri.CreateHttpsUrl());

            httpWebRequest.ServerCertificateValidationCallback =
                ServerCertificateValidationCallbackGenerator(expectedServerRsaKey);
            httpWebRequest.ClientCertificates.Add(clientCertificate);

            // There is a bug in TJWS that doesn't handle Expect 100 Continue correctly
            httpWebRequest.ServicePoint.Expect100Continue = false;

            // This is a desperate bid to see if our perf issues are because we are recycling TCP connections too quickly, I tend to doubt it.
            httpWebRequest.ServicePoint.SetTcpKeepAlive(true, 1000, 10 * 1000);

            // Nagle combines small packets into big packets which is very good on long haul connections but we are only talking locally
            httpWebRequest.ServicePoint.UseNagleAlgorithm = false;

            // Since most of our requests are anyway serially I doubt this will help but I'm desperate so let's try.
            httpWebRequest.ServicePoint.ConnectionLimit = 100;

            return(httpWebRequest);
        }