private static void SetRequestContent(HttpWebRequest webRequest,
                                              ServiceRequest serviceRequest)
        {
            var data = serviceRequest.BuildRequestContent();

            if (data == null ||
                (serviceRequest.Method != HttpMethod.Put &&
                 serviceRequest.Method != HttpMethod.Post))
            {
                // Skip setting content body in this case.
                webRequest.ContentLength = 0;
                return;
            }

            // Write data to the request stream.
            long userSetContentLength = -1;

            if (serviceRequest.Headers.ContainsKey(Aliyun.Api.LOG.Common.Utilities.HttpHeaders.ContentLength))
            {
                userSetContentLength = long.Parse(serviceRequest.Headers[Aliyun.Api.LOG.Common.Utilities.HttpHeaders.ContentLength]);
            }

            long streamLength = data.Length - data.Position;

            webRequest.ContentLength = (userSetContentLength >= 0 && userSetContentLength <= streamLength) ?
                                       userSetContentLength : streamLength;

            webRequest.KeepAlive = false;
            webRequest.ServicePoint.ConnectionLeaseTimeout = 5000;
            webRequest.ServicePoint.MaxIdleTime            = 5000;
            webRequest.ServicePoint.ConnectionLimit        = 1000;
            webRequest.ServicePoint.Expect100Continue      = false;
            // Generate GUID for connection group name, force close it when request is done.
            webRequest.ConnectionGroupName = Guid.NewGuid().ToString();

            using (var requestStream = webRequest.GetRequestStream())
            {
                data.WriteTo(requestStream, webRequest.ContentLength);
                data.Seek(0, SeekOrigin.Begin);
                requestStream.Flush();
                requestStream.Close();
            }
            data.Close();
            data.Dispose();
        }
        private static void SetRequestContent(HttpWebRequest webRequest,
                                              ServiceRequest serviceRequest)
        {
            var data = serviceRequest.BuildRequestContent();

            if (data == null ||
                (serviceRequest.Method != HttpMethod.Put &&
                 serviceRequest.Method != HttpMethod.Post))
            {
                // Skip setting content body in this case.
                webRequest.ContentLength = 0;
                return;
            }

            // Write data to the request stream.
            long userSetContentLength = -1;

            if (serviceRequest.Headers.ContainsKey(HttpHeaders.ContentLength))
            {
                userSetContentLength = long.Parse(serviceRequest.Headers[HttpHeaders.ContentLength]);
            }

            long streamLength = data.Length - data.Position;

            webRequest.ContentLength = (userSetContentLength >= 0 && userSetContentLength <= streamLength) ?
                                       userSetContentLength : streamLength;

            //webRequest.
            //webRequest.KeepAlive = true;
            //webRequest.ReadWriteTimeout = 100000000;
            //webRequest.ServicePoint.ConnectionLimit = 100000;
            //webRequest.Timeout = Configuration
            using (var requestStream = webRequest.GetRequestStream())
            {
                data.WriteTo(requestStream, webRequest.ContentLength);
                data.Seek(0, SeekOrigin.Begin);
            }
        }