CreateRequest() public static method

建立请求
public static CreateRequest ( string method, string url, int timeout ) : HttpWebRequest
method string
url string
timeout int
return System.Net.HttpWebRequest
Esempio n. 1
0
        /// <summary>
        /// POST请求
        /// </summary>
        /// <returns></returns>
        private void Post(string contentType)
        {
            HttpWebRequest request = HttpUtil.CreateRequest("POST", Url, Timeout);

            request.ContentType = contentType;
            request.AllowReadStreamBuffering = true;

            if (Parameters != null && Parameters.Items.Count != 0)
            {
                request.BeginGetRequestStream(GetRequestStreamCallback, request);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// GET请求
        /// </summary>
        /// <returns></returns>
        private void Get()
        {
            string queryString = Parameters == null ? "" : Parameters.BuildQueryString(true);
            string url         = Url;

            if (!string.IsNullOrEmpty(queryString))
            {
                url = string.Concat(url, url.IndexOf('?') == -1 ? '?' : '&', queryString);
            }
            HttpWebRequest request = HttpUtil.CreateRequest("GET", url, Timeout);

            request.BeginGetResponse(AsyncResponseCallback, request);
        }
Esempio n. 3
0
        /// <summary>
        /// Post请求,带图片
        /// </summary>
        /// <param name="responseEnd"></param>
        /// <param name="files"></param>
        /// <param name="callback"></param>
        public void PostFile(Action <string, Action <string> > responseEnd, Files files, Action <string> callback)
        {
            OAuthCallback  = callback;
            OAuthEndAction = responseEnd;
            Files          = files;

            HttpWebRequest request = HttpUtil.CreateRequest("POST", Url, Timeout);

            request.Headers["Authorization"] = AuthHeader;
            if (Parameters != null && Parameters.Items.Count != 0)
            {
                request.BeginGetRequestStream(GetPostFileRequestStreamCallback, request);
            }
        }