示例#1
0
        /**
         * Configure HttpClient with set of defaults as well as configuration
         * from AmazonCloudWatchConfig instance
         */
        private static HttpWebRequest ConfigureWebRequest(int contentLength, AmazonCloudWatchConfig config)
        {
            HttpWebRequest request = WebRequest.Create(config.ServiceURL) as HttpWebRequest;

            if (request != null)
            {
                if (config.IsSetProxyHost() && config.IsSetProxyPort())
                {
                    WebProxy proxy = new WebProxy(config.ProxyHost, config.ProxyPort);
                    if (config.IsSetProxyUsername())
                    {
                        proxy.Credentials = new NetworkCredential(
                            config.ProxyUsername,
                            config.ProxyPassword ?? String.Empty
                            );
                    }
                    request.Proxy = proxy;
                }
                request.UserAgent     = config.UserAgent;
                request.Method        = "POST";
                request.Timeout       = 50000;
                request.ContentType   = AWSSDKUtils.UrlEncodedContent;
                request.ContentLength = contentLength;
            }

            return(request);
        }
        private static HttpWebRequest ConfigureWebRequest(int contentLength, AmazonCloudWatchConfig config)
        {
            HttpWebRequest request = WebRequest.Create(config.ServiceURL) as HttpWebRequest;

            if (request != null)
            {
                if (config.IsSetProxyHost() && config.IsSetProxyPort())
                {
                    WebProxy proxy = new WebProxy(config.ProxyHost, config.ProxyPort);
                    if (config.IsSetProxyUsername())
                    {
                        proxy.Credentials = new NetworkCredential(config.ProxyUsername, config.ProxyPassword ?? string.Empty);
                    }
                    request.Proxy = proxy;
                }
                request.UserAgent     = config.UserAgent;
                request.Method        = "POST";
                request.Timeout       = 0xc350;
                request.ContentType   = "application/x-www-form-urlencoded; charset=utf-8";
                request.ContentLength = contentLength;
            }
            return(request);
        }