Skip to content

Commit 2c74734

Browse files
committed
downgrade http 1 when keepalive = false
only tls1.2 add dns refresh timeout
1 parent 004beb2 commit 2c74734

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

ru.org.openam.sdk/pll/Request.cs

+11-5
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ public enum type
2323
public abstract class Request
2424
{
2525
static Request(){
26-
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
27-
ServicePointManager.DefaultConnectionLimit = 128;
28-
ServicePointManager.Expect100Continue = false;
26+
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
27+
ServicePointManager.DefaultConnectionLimit = 128;
28+
ServicePointManager.DnsRefreshTimeout = 60*1000;
29+
//ServicePointManager.EnableDnsRoundRobin = true;
30+
ServicePointManager.Expect100Continue = false;
2931
ServicePointManager.SetTcpKeepAlive(true,15*1000,5*1000);
3032
ServicePointManager.MaxServicePointIdleTime = 14 * 1000; //https://support.microsoft.com/ru-ru/help/2017977/the-underlying-connection-was-closed-a-connection-that-was-expected-to
31-
if ("true".Equals(ConfigurationManager.AppSettings["com.sun.identity.agents.config.trust.server.certs"]))
33+
ServicePointManager.MaxServicePoints = 0;
34+
ServicePointManager.MaxServicePointIdleTime = 10*1000;
35+
if ("true".Equals(ConfigurationManager.AppSettings["com.sun.identity.agents.config.trust.server.certs"]))
3236
ServicePointManager.ServerCertificateValidationCallback +=
3337
delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
3438
System.Security.Cryptography.X509Certificates.X509Chain chain,
@@ -82,11 +86,13 @@ HttpWebRequest getHttpWebRequest()
8286
{
8387
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(getUrl());
8488
request.KeepAlive =KeepAlive();
85-
request.AutomaticDecompression = DecompressionMethods.None; //TODO configure
89+
request.ProtocolVersion = (request.KeepAlive) ? HttpVersion.Version11 : HttpVersion.Version10;
90+
request.AutomaticDecompression = DecompressionMethods.None; //TODO configure
8691
request.Method = getMethod();
8792
request.ContentType = getContentType();
8893
request.UserAgent = UserAgent;
8994
request.CookieContainer = getCookieContainer();
95+
request.Proxy = null;
9096
int connect_timeout=5000,receive_timeout=15000;
9197
if (Agent.Instance.HasConfig()) {
9298
int.TryParse (Agent.Instance.GetSingle ("com.sun.identity.agents.config.connect.timeout"), out connect_timeout);

0 commit comments

Comments
 (0)