public static GetDefault ( string configKey ) : string | ||
configKey | string | The key to lookup in the default configuration. |
Результат | string |
/// <summary> /// Create and Config a HttpWebRequest /// </summary> /// <param name="config">Config properties</param> /// <param name="url">Url to connect to</param> /// <returns></returns> public HttpWebRequest GetConnection(Dictionary <string, string> config, string url) { HttpWebRequest httpRequest = null; try { httpRequest = (HttpWebRequest)WebRequest.Create(url); } catch (UriFormatException ex) { throw new ConfigException("Invalid URI: " + url); } // Set connection timeout int ConnectionTimeout = 0; if (!config.ContainsKey(BaseConstants.HttpConnectionTimeoutConfig) || !int.TryParse(config[BaseConstants.HttpConnectionTimeoutConfig], out ConnectionTimeout)) { int.TryParse(ConfigManager.GetDefault(BaseConstants.HttpConnectionTimeoutConfig), out ConnectionTimeout); } httpRequest.Timeout = ConnectionTimeout; // Set request proxy for tunnelling http requests via a proxy server if (config.ContainsKey(BaseConstants.HttpProxyAddressConfig)) { WebProxy requestProxy = new WebProxy(); requestProxy.Address = new Uri(config[BaseConstants.HttpProxyAddressConfig]); if (config.ContainsKey(BaseConstants.HttpProxyCredentialConfig)) { string proxyCredentials = config[BaseConstants.HttpProxyCredentialConfig]; string[] proxyDetails = proxyCredentials.Split(':'); if (proxyDetails.Length == 2) { requestProxy.Credentials = new NetworkCredential(proxyDetails[0], proxyDetails[1]); } } httpRequest.Proxy = requestProxy; } // Don't set the Expect: 100-continue header as it's not supported // well by Akamai and can negatively impact performance. httpRequest.ServicePoint.Expect100Continue = false; if (this.logTlsWarning) { throw new InvalidOperationException( "SECURITY WARNING: TLSv1.2 is not supported on this system. Please update your .NET framework to a version that supports TLSv1.2."); } return(httpRequest); }
/// <summary> /// Create and Config a HttpWebRequest /// </summary> /// <param name="config">Config properties</param> /// <param name="url">Url to connect to</param> /// <returns></returns> public HttpWebRequest GetConnection(Dictionary <string, string> config, string url) { HttpWebRequest httpRequest = null; try { httpRequest = (HttpWebRequest)WebRequest.Create(url); } catch (UriFormatException ex) { logger.Error(ex.Message, ex); throw new ConfigException("Invalid URI: " + url); } // Set connection timeout int ConnectionTimeout = 0; if (!config.ContainsKey(BaseConstants.HttpConnectionTimeoutConfig) || !int.TryParse(config[BaseConstants.HttpConnectionTimeoutConfig], out ConnectionTimeout)) { int.TryParse(ConfigManager.GetDefault(BaseConstants.HttpConnectionTimeoutConfig), out ConnectionTimeout); } httpRequest.Timeout = ConnectionTimeout; // Set request proxy for tunnelling http requests via a proxy server if (config.ContainsKey(BaseConstants.HttpProxyAddressConfig)) { WebProxy requestProxy = new WebProxy(); requestProxy.Address = new Uri(config[BaseConstants.HttpProxyAddressConfig]); if (config.ContainsKey(BaseConstants.HttpProxyCredentialConfig)) { string proxyCredentials = config[BaseConstants.HttpProxyCredentialConfig]; string[] proxyDetails = proxyCredentials.Split(':'); if (proxyDetails.Length == 2) { requestProxy.Credentials = new NetworkCredential(proxyDetails[0], proxyDetails[1]); } } httpRequest.Proxy = requestProxy; } return(httpRequest); }