protected override HttpWebRequest OnGetHttpWebRequest(Uri uri) { var result = WebRequest.Create(uri) as HttpWebRequest; if (result == null) { return(null); } result.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip; result.Proxy = WebProxyFactory.GetInstance().GetWebProxy(); result.ServicePoint.Expect100Continue = false; result.Timeout = GetTimeoutInMilli(); result.UserAgent = GetUserAgentString(); return(result); }
private static WebProxyFactory DoGetInstance(Type type) { if (type == null) { throw new ArgumentException("Invalid arguments to get " + typeof(WebProxyFactory).Name + " instance"); } var key = type.FullName + "_"; WebProxyFactory instance = null; if (Instances.ContainsKey(key)) { instance = Instances[key]; } if (instance == null) { Logger.GetInstance(typeof(WebProxyFactory)).Info("Initializing " + key + "..."); var constructor = type.GetConstructor(new Type[] { }); if (constructor != null) { instance = (WebProxyFactory)constructor.Invoke(new object[] { }); } } if (instance == null) { Logger.GetInstance(typeof(WebProxyFactory)).Info("Initializing " + typeof(DefaultWebProxyFactory).FullName + "..."); instance = new DefaultWebProxyFactory(); } lock (InstancesLock) { if (!Instances.ContainsKey(key)) { Instances.Add(key, instance); } } return(instance); }