C# Class Thrinax.Helper.HttpHelper

Datei anzeigen Open project: ziyunhx/thrinax

Public Methods

Method Description
ConvertToCookieContainer ( string>.Dictionary cookies ) : CookieContainer

convert cookies string to CookieContainer

CreateGetHttpResponse ( string url, int timeout = 8000, string userAgent = null, CookieContainer cookies = null, string referer = null, IWebProxy proxy = null, string contentType = null, string>.Dictionary headers = null ) : HttpWebResponse

创建GET方式的HTTP请求

CreatePostHttpResponse ( string url, string postData, int timeout = 8000, string userAgent = null, CookieContainer cookies = null, string referer = null, IWebProxy proxy = null, string contentType = null, string>.Dictionary headers = null ) : HttpWebResponse

创建POST方式的HTTP请求

GetAllCookies ( CookieContainer cookieContainer ) : string>.Dictionary

Get all cookies from CookieContainer.

GetHttpContent ( string url, string postData = null, CookieContainer cookies = null, string userAgent = null, string referer = null, string cookiesDomain = null, Encoding encode = null, string method = null, IWebProxy proxy = null, string encoding = null, string contentType = null, int timeout = 8000, string>.Dictionary headers = null ) : string

获取网页的内容

HttpRequest ( string url, string postData = null, CookieContainer cookies = null, string userAgent = null, string referer = null, string cookiesDomain = null, Encoding encode = null, string method = null, IWebProxy proxy = null, string encoding = null, string contentType = null, int timeout = 8000, string>.Dictionary headers = null ) : Thrinax.Data.HttpResult

使用Http Request获取网页信息

Private Methods

Method Description
CheckValidationResult ( object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors ) : bool

验证证书

DetermineResultStatus ( Exception ex ) : int

根据异常内容判断状态类型

SetCookie ( HttpWebResponse response, string defaultDomain ) : CookieCollection

根据response中头部的set-cookie对request中的cookie进行设置

Method Details

ConvertToCookieContainer() public static method

convert cookies string to CookieContainer
public static ConvertToCookieContainer ( string>.Dictionary cookies ) : CookieContainer
cookies string>.Dictionary cookies dictionary.
return System.Net.CookieContainer

CreateGetHttpResponse() public static method

创建GET方式的HTTP请求
public static CreateGetHttpResponse ( string url, int timeout = 8000, string userAgent = null, CookieContainer cookies = null, string referer = null, IWebProxy proxy = null, string contentType = null, string>.Dictionary headers = null ) : HttpWebResponse
url string
timeout int
userAgent string
cookies System.Net.CookieContainer
referer string
proxy IWebProxy
contentType string
headers string>.Dictionary
return System.Net.HttpWebResponse

CreatePostHttpResponse() public static method

创建POST方式的HTTP请求
public static CreatePostHttpResponse ( string url, string postData, int timeout = 8000, string userAgent = null, CookieContainer cookies = null, string referer = null, IWebProxy proxy = null, string contentType = null, string>.Dictionary headers = null ) : HttpWebResponse
url string
postData string
timeout int
userAgent string
cookies System.Net.CookieContainer
referer string
proxy IWebProxy
contentType string
headers string>.Dictionary
return System.Net.HttpWebResponse

GetAllCookies() public static method

Get all cookies from CookieContainer.
public static GetAllCookies ( CookieContainer cookieContainer ) : string>.Dictionary
cookieContainer System.Net.CookieContainer the CookieContainer
return string>.Dictionary

GetHttpContent() public static method

获取网页的内容
public static GetHttpContent ( string url, string postData = null, CookieContainer cookies = null, string userAgent = null, string referer = null, string cookiesDomain = null, Encoding encode = null, string method = null, IWebProxy proxy = null, string encoding = null, string contentType = null, int timeout = 8000, string>.Dictionary headers = null ) : string
url string Url
postData string Post的信息
cookies System.Net.CookieContainer Cookies
userAgent string 浏览器标识
referer string 来源页
cookiesDomain string Cookies的Domian参数,配合cookies使用;为空则取url的Host
encode System.Text.Encoding 编码方式,用于解析html
method string 提交方式,例如POST或GET,默认通过postData是否为空判断
proxy IWebProxy
encoding string
contentType string
timeout int
headers string>.Dictionary
return string

HttpRequest() public static method

使用Http Request获取网页信息
public static HttpRequest ( string url, string postData = null, CookieContainer cookies = null, string userAgent = null, string referer = null, string cookiesDomain = null, Encoding encode = null, string method = null, IWebProxy proxy = null, string encoding = null, string contentType = null, int timeout = 8000, string>.Dictionary headers = null ) : Thrinax.Data.HttpResult
url string Url
postData string Post的信息
cookies System.Net.CookieContainer Cookies
userAgent string 浏览器标识
referer string 来源页
cookiesDomain string Cookies的Domian参数,配合cookies使用;为空则取url的Host
encode System.Text.Encoding 编码方式,用于解析html
method string 提交方式,例如POST或GET,默认通过postData是否为空判断
proxy IWebProxy
encoding string
contentType string
timeout int
headers string>.Dictionary
return Thrinax.Data.HttpResult