当前位置: 首页>>代码示例>>C#>>正文


C# Net.HttpVerb类代码示例

本文整理汇总了C#中System.Net.HttpVerb的典型用法代码示例。如果您正苦于以下问题:C# HttpVerb类的具体用法?C# HttpVerb怎么用?C# HttpVerb使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpVerb类属于System.Net命名空间,在下文中一共展示了HttpVerb类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPageAsync

        public async Task<string> GetPageAsync(string url, HttpVerb verb, string referrer = null)
        {
            var responseText = "";

            using (var request = RequestBuilder.Build(url, CommonHeaders(referrer), CookieJar))
            {
                request.Method = verb.ToVerbString();

                using (var response = await request.GetResponseAsync().ConfigureAwait(false))
                {
                    using (var stream = await response.GetResponseStreamAsync())
                    {
                        using (var sr = new StreamReader(stream))
                        {
                            responseText = sr.ReadToEnd();
                        }
                    }

                    var doc = new HtmlDocument();
                    doc.LoadHtml(responseText);

                    var scripts = doc.DocumentNode.Descendants("script");
                    foreach (var s in scripts.Where(s => s.InnerText.Contains("top.location")))
                    {
                        var newUrl = s.InnerText.Split('=')[1].Trim().Trim(new[] {' ', ';', '"'});
                        return await GetPageAsync(newUrl, verb).ConfigureAwait(false);
                    }
                }
            }

            return responseText;
        }
开发者ID:CrshOverride,项目名称:CourseraDotNet,代码行数:32,代码来源:Session.cs

示例2: RestClient

 public RestClient(string endpoint, HttpVerb method)
 {
     EndPoint = endpoint;
     Method = method;
     ContentType = "application/json";//"text/xml";
     PostData = "";
 }
开发者ID:jhamadhukar,项目名称:KryptonService,代码行数:7,代码来源:RestClient.cs

示例3: RestClient

		/**
         * RestClient with an end point, request type, post-data if any and content type
         */
        public RestClient (string endpoint, HttpVerb method, string postData,string contentTypeIdentifier)
        {
            EndPoint = endpoint;
            Method = method;
            ContentType = contentTypeIdentifier;
            PostData = postData;
        }
开发者ID:mabhi,项目名称:crossdevicepoc,代码行数:10,代码来源:RestClient.cs

示例4: RestClient

 public RestClient(string endpoint, HttpVerb method, string postData)
     : this()
 {
     EndPoint = endpoint;
     Method = method;
     PostData = postData;
 }
开发者ID:cavevs,项目名称:Clusterpoint-Client,代码行数:7,代码来源:RestClient.cs

示例5: SimpleRestClient

 public SimpleRestClient(string endpoint, HttpVerb method)
 {
     EndPoint = endpoint;
     Method = method;
     ContentType = "text/json";
     PostData = string.Empty;
 }
开发者ID:stonstad,项目名称:Signcast,代码行数:7,代码来源:SimpleRestClient.cs

示例6: RestHelper

 public RestHelper(string endpoint, HttpVerb method)
 {
     EndPoint = endpoint;
     Method = method;
     ContentType = "application/json";
     PostData = "";
 }
开发者ID:srihari-sridharan,项目名称:ActivityTracker,代码行数:7,代码来源:RESTHelper.cs

示例7: MakeRequest

        /// <summary>
        /// Make an HTTP request, with the given query args
        /// </summary>
        /// <param name="url">The URL of the request</param>
        /// <param name="httpVerb">The HTTP verb to use</param>
        /// <param name="argument">String thar represents the request data, must be in JSON format</param>
        private static string MakeRequest(Uri url, HttpVerb httpVerb, string argument = null)
        {
            var request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = httpVerb.ToString();
            request.ContentType = "application/json";

            if (httpVerb == HttpVerb.POST)
            {
                var encoding = new ASCIIEncoding();
                var postDataBytes = new byte[0];
                if (argument != null)
                {
                    postDataBytes = encoding.GetBytes(argument);
                }

                request.ContentLength = postDataBytes.Length;

                var requestStream = request.GetRequestStream();
                requestStream.Write(postDataBytes, 0, postDataBytes.Length);
                requestStream.Close();
            }

            try
            {
                using (var response = (HttpWebResponse)request.GetResponse())
                {
                    var reader = new StreamReader(response.GetResponseStream());
                    return reader.ReadToEnd();
                }
            }
            catch (WebException e)
            {
                throw new CoticulaApiException("Server Error", e.Message);
            }
        }
开发者ID:brus07,项目名称:coticula,代码行数:41,代码来源:JsonWebClient.cs

示例8: RestClient

 public RestClient(string endpoint, HttpVerb method, Object postObj)
 {
     this.EndPoint = endpoint;
     this.Method = method;
     this.ContentType = "application/json;charset=UTF-8";
     this.PostData = Newtonsoft.Json.JsonConvert.SerializeObject(postObj);
 }
开发者ID:CapricornZ,项目名称:autobid,代码行数:7,代码来源:RestClient.cs

示例9: Build

        /// <summary>
        /// Builds a HTTP request from the given arguments.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="verb">The verb.</param>
        /// <param name="agent">The agent.</param>
        /// <param name="cookies">The cookies.</param>
        /// <param name="referer">The referer.</param>
        /// <param name="retries">The retries.</param>
        /// <param name="timeout">The timeout.</param>
        /// <param name="accept">The accept.</param>
        /// <param name="encoding">The encoding.</param>
        /// <returns></returns>
        public HttpRequest Build(string url, HttpVerb verb , string agent, CookieContainer cookies = null, string referer = "", int retries = 0, int timeout = 10000, BaseMime accept = null, Encoding encoding = null)
        {
            var request = new HttpRequest
                          {
                              Url = url,
                              UserAgent = agent,
                              Verb = verb,
                              Referer = referer,
                              Retries = retries,
                              Timeout = timeout,
                              Encoding = encoding ?? Encoding.UTF8
                          };

            if (accept != null)
            {
                request.Accept = accept.ToString();
            }

            if (cookies != null)
            {
                request.Cookies = cookies;
            }

            return request;
        }
开发者ID:comsechq,项目名称:sugar,代码行数:38,代码来源:HttpService.cs

示例10: HttpClient

        public HttpClient(string endpoint, HttpVerb httpVerb, NameValueCollection headers, string contentType, string parameters)
        {
            try
            {
                this.Request = (HttpWebRequest)WebRequest.Create(endpoint);
                this.Request.ContentLength = 0;
                this.Request.ContentType = contentType.ToString();
                this.Request.Method = httpVerb.ToString();

                if (headers != null)
                {
                    foreach (var key in headers.AllKeys)
                    {
                        this.Request.Headers.Add(key, headers[key]);
                    }
                }

                if (this.Request.Method == HttpVerb.POST.ToString() && !String.IsNullOrEmpty(parameters))
                {
                    var encoding = new UTF8Encoding();
                    var bytes = Encoding.GetEncoding("utf-8").GetBytes(parameters);

                    this.Request.ContentLength = bytes.Length;

                    using (var writeStream = Request.GetRequestStream())
                    {
                        writeStream.Write(bytes, 0, bytes.Length);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException(String.Format("Create WebRequest Error: {0}", ex.Message));
            }
        }
开发者ID:vgreggio,项目名称:CrossoverTest,代码行数:35,代码来源:HttpClient.cs

示例11: RestClient

 public RestClient(string endpoint, HttpVerb method, string postData)
 {
     EndPoint = endpoint;
     Method = method;
     ContentType = "application/json";
     PostData = postData;
 }
开发者ID:Dmdv,项目名称:MeltoxygenCalculator,代码行数:7,代码来源:RestClient.cs

示例12: WebRequestUtility

        public WebRequestUtility(string realm, Uri requestUri, HttpVerb verb, Boolean keepAlive, String userAgent, NetworkCredential networkCredentials)
        {
            if (requestUri == null)
                throw new ArgumentNullException("requestUri");

            this.Realm = realm;
            this.RequestUri = requestUri;
            this.Verb = verb;
            this.KeepAlive = keepAlive;
            this.UserAgent = userAgent;
            this.UseOAuth = false;
            if (networkCredentials != null)
                this.NetworkCredentials = networkCredentials;

            this.Parameters = new Dictionary<string, object>();

            if (string.IsNullOrEmpty(this.RequestUri.Query)) return;

            foreach (Match item in Regex.Matches(this.RequestUri.Query, @"(?<key>[^&?=]+)=(?<value>[^&?=]+)"))
            {
                this.Parameters.Add(item.Groups["key"].Value, item.Groups["value"].Value);
            }

            this.RequestUri = new Uri(this.RequestUri.AbsoluteUri.Replace(this.RequestUri.Query, ""));
        }
开发者ID:davidyancey,项目名称:simple-cms,代码行数:25,代码来源:WebRequestUtility.cs

示例13: RestClient

 public RestClient(string endpoint, string command, HttpVerb method)
 {
     _params = new Dictionary<string, string>();
     EndPoint = endpoint;
     Command = command;
     Method = method;
     ContentType = "text/xml";
     PostData = string.Empty;
 }
开发者ID:rpropst,项目名称:sa-demo,代码行数:9,代码来源:RestClient.cs

示例14: RestClient

 public RestClient(string endpoint, HttpVerb method, string postData, string callType, string token)
 {
     EndPoint = endpoint;
     Method = method;
     ContentType = "application/json";
     CallType = callType;
     PostData = postData;
     Token = token;
 }
开发者ID:shahdat45ict,项目名称:gocoin-.net,代码行数:9,代码来源:RestClient.cs

示例15: MakeRequest

            public void MakeRequest(HttpVerb method, string url, HeaderProvider header, AuthenticationProvider auth, BodyProvider body)
            {
                this.method = method;
                this.url = url;
                this.headers = header;
                this.auth = auth;
                this.body = body;

                this.MakeRequest();
            }
开发者ID:RainsSoft,项目名称:httplib,代码行数:10,代码来源:RequestTest.cs


注:本文中的System.Net.HttpVerb类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。