C# 클래스 Senparc.Weixin.HttpUtility.RequestUtility

파일 보기 프로젝트 열기: JeffreySu/WeiXinMPSDK 1 사용 예제들

공개 메소드들

메소드 설명
AsUrlData ( this data ) : string

将 URL 中的参数名称/值编码为合法的格式。

可以解决类似这样的问题:假设参数名为 tvshow, 参数值为 Tom&Jerry,如果不编码,可能得到的网址: http://a.com/?tvshow=Tom&Jerry&year=1965 编码后则为:http://a.com/?tvshow=Tom%26Jerry&year=1965

实践中经常导致问题的字符有:'&', '?', '=' 等

FillFormDataStream ( string>.this formData, Stream stream ) : void

填充表单信息的Stream

FillFormDataStreamAsync ( string>.this formData, Stream stream ) : System.Threading.Tasks.Task

填充表单信息的Stream

GetQueryString ( string>.this formData ) : string

组装QueryString的方法 参数之间用&连接,首位没有符号,如:a=1&b=2&c=3

HtmlDecode ( this html ) : string

封装System.Web.HttpUtility.HtmlDecode

HtmlEncode ( this html ) : string

封装System.Web.HttpUtility.HtmlEncode

HttpGet ( string url, CookieContainer cookieContainer = null, Encoding encoding = null, X509Certificate cer = null, int timeOut = Config.TIME_OUT ) : string

使用Get方法获取字符串结果(加入Cookie)

HttpGet ( string url, Encoding encoding = null ) : string

使用Get方法获取字符串结果(没有加入Cookie)

HttpGetAsync ( string url, CookieContainer cookieContainer = null, Encoding encoding = null, X509Certificate cer = null, int timeOut = Config.TIME_OUT ) : Task

使用Get方法获取字符串结果(加入Cookie)

HttpGetAsync ( string url, Encoding encoding = null ) : Task

使用Get方法获取字符串结果(没有加入Cookie)

HttpPost ( string url, CookieContainer cookieContainer = null, string>.Dictionary formData = null, Encoding encoding = null, X509Certificate cer = null, int timeOut = Config.TIME_OUT ) : string

使用Post方法获取字符串结果,常规提交

HttpPost ( string url, CookieContainer cookieContainer = null, Stream postStream = null, string>.Dictionary fileDictionary = null, string refererUrl = null, Encoding encoding = null, X509Certificate cer = null, int timeOut = Config.TIME_OUT, bool checkValidationResult = false ) : string

使用Post方法获取字符串结果

HttpPostAsync ( string url, CookieContainer cookieContainer = null, string>.Dictionary formData = null, Encoding encoding = null, X509Certificate cer = null, int timeOut = Config.TIME_OUT ) : Task

使用Post方法获取字符串结果,常规提交

HttpPostAsync ( string url, CookieContainer cookieContainer = null, Stream postStream = null, string>.Dictionary fileDictionary = null, string refererUrl = null, Encoding encoding = null, X509Certificate cer = null, int timeOut = Config.TIME_OUT, bool checkValidationResult = false ) : Task

使用Post方法获取字符串结果

RemoveHttpProxy ( ) : void

清除Web代理状态

SetHttpProxy ( string host, string port, string username, string password ) : void

设置Web代理

UrlDecode ( this url ) : string

封装System.Web.HttpUtility.UrlDecode

UrlEncode ( this url ) : string

封装System.Web.HttpUtility.UrlEncode

비공개 메소드들

메소드 설명
CheckValidationResult ( object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors ) : bool

验证服务器证书

IsWeixinClientRequest ( this httpContext ) : bool

메소드 상세

AsUrlData() 공개 정적인 메소드

将 URL 中的参数名称/值编码为合法的格式。

可以解决类似这样的问题:假设参数名为 tvshow, 参数值为 Tom&Jerry,如果不编码,可能得到的网址: http://a.com/?tvshow=Tom&Jerry&year=1965 编码后则为:http://a.com/?tvshow=Tom%26Jerry&year=1965

实践中经常导致问题的字符有:'&', '?', '=' 等

public static AsUrlData ( this data ) : string
data this
리턴 string

FillFormDataStream() 공개 정적인 메소드

填充表单信息的Stream
public static FillFormDataStream ( string>.this formData, Stream stream ) : void
formData string>.this
stream Stream
리턴 void

FillFormDataStreamAsync() 공개 정적인 메소드

填充表单信息的Stream
public static FillFormDataStreamAsync ( string>.this formData, Stream stream ) : System.Threading.Tasks.Task
formData string>.this
stream Stream
리턴 System.Threading.Tasks.Task

GetQueryString() 공개 정적인 메소드

组装QueryString的方法 参数之间用&连接,首位没有符号,如:a=1&b=2&c=3
public static GetQueryString ( string>.this formData ) : string
formData string>.this
리턴 string

HtmlDecode() 공개 정적인 메소드

封装System.Web.HttpUtility.HtmlDecode
public static HtmlDecode ( this html ) : string
html this
리턴 string

HtmlEncode() 공개 정적인 메소드

封装System.Web.HttpUtility.HtmlEncode
public static HtmlEncode ( this html ) : string
html this
리턴 string

HttpGet() 공개 정적인 메소드

使用Get方法获取字符串结果(加入Cookie)
public static HttpGet ( string url, CookieContainer cookieContainer = null, Encoding encoding = null, X509Certificate cer = null, int timeOut = Config.TIME_OUT ) : string
url string
cookieContainer System.Net.CookieContainer
encoding System.Text.Encoding
cer System.Security.Cryptography.X509Certificates.X509Certificate 证书,如果不需要则保留null
timeOut int
리턴 string

HttpGet() 공개 정적인 메소드

使用Get方法获取字符串结果(没有加入Cookie)
public static HttpGet ( string url, Encoding encoding = null ) : string
url string
encoding System.Text.Encoding
리턴 string

HttpGetAsync() 공개 정적인 메소드

使用Get方法获取字符串结果(加入Cookie)
public static HttpGetAsync ( string url, CookieContainer cookieContainer = null, Encoding encoding = null, X509Certificate cer = null, int timeOut = Config.TIME_OUT ) : Task
url string
cookieContainer System.Net.CookieContainer
encoding System.Text.Encoding
cer System.Security.Cryptography.X509Certificates.X509Certificate 证书,如果不需要则保留null
timeOut int
리턴 Task

HttpGetAsync() 공개 정적인 메소드

使用Get方法获取字符串结果(没有加入Cookie)
public static HttpGetAsync ( string url, Encoding encoding = null ) : Task
url string
encoding System.Text.Encoding
리턴 Task

HttpPost() 공개 정적인 메소드

使用Post方法获取字符串结果,常规提交
public static HttpPost ( string url, CookieContainer cookieContainer = null, string>.Dictionary formData = null, Encoding encoding = null, X509Certificate cer = null, int timeOut = Config.TIME_OUT ) : string
url string
cookieContainer System.Net.CookieContainer
formData string>.Dictionary
encoding System.Text.Encoding
cer System.Security.Cryptography.X509Certificates.X509Certificate
timeOut int
리턴 string

HttpPost() 공개 정적인 메소드

使用Post方法获取字符串结果
public static HttpPost ( string url, CookieContainer cookieContainer = null, Stream postStream = null, string>.Dictionary fileDictionary = null, string refererUrl = null, Encoding encoding = null, X509Certificate cer = null, int timeOut = Config.TIME_OUT, bool checkValidationResult = false ) : string
url string
cookieContainer System.Net.CookieContainer
postStream Stream
fileDictionary string>.Dictionary 需要上传的文件,Key:对应要上传的Name,Value:本地文件名
refererUrl string
encoding System.Text.Encoding
cer System.Security.Cryptography.X509Certificates.X509Certificate 证书,如果不需要则保留null
timeOut int
checkValidationResult bool 验证服务器证书回调自动验证
리턴 string

HttpPostAsync() 공개 정적인 메소드

使用Post方法获取字符串结果,常规提交
public static HttpPostAsync ( string url, CookieContainer cookieContainer = null, string>.Dictionary formData = null, Encoding encoding = null, X509Certificate cer = null, int timeOut = Config.TIME_OUT ) : Task
url string
cookieContainer System.Net.CookieContainer
formData string>.Dictionary
encoding System.Text.Encoding
cer System.Security.Cryptography.X509Certificates.X509Certificate
timeOut int
리턴 Task

HttpPostAsync() 공개 정적인 메소드

使用Post方法获取字符串结果
public static HttpPostAsync ( string url, CookieContainer cookieContainer = null, Stream postStream = null, string>.Dictionary fileDictionary = null, string refererUrl = null, Encoding encoding = null, X509Certificate cer = null, int timeOut = Config.TIME_OUT, bool checkValidationResult = false ) : Task
url string
cookieContainer System.Net.CookieContainer
postStream Stream
fileDictionary string>.Dictionary 需要上传的文件,Key:对应要上传的Name,Value:本地文件名
refererUrl string
encoding System.Text.Encoding
cer System.Security.Cryptography.X509Certificates.X509Certificate
timeOut int
checkValidationResult bool 验证服务器证书回调自动验证
리턴 Task

RemoveHttpProxy() 공개 정적인 메소드

清除Web代理状态
public static RemoveHttpProxy ( ) : void
리턴 void

SetHttpProxy() 공개 정적인 메소드

设置Web代理
public static SetHttpProxy ( string host, string port, string username, string password ) : void
host string
port string
username string
password string
리턴 void

UrlDecode() 공개 정적인 메소드

封装System.Web.HttpUtility.UrlDecode
public static UrlDecode ( this url ) : string
url this
리턴 string

UrlEncode() 공개 정적인 메소드

封装System.Web.HttpUtility.UrlEncode
public static UrlEncode ( this url ) : string
url this
리턴 string