using System; using System.Net; using System.Net.Security; using System.Security.Cryptography.X509Certificates; using System.Text; namespace POSV.HttpRequest { /// /// Http连接操作帮助类 /// public partial class HttpHelper { /// /// 请求参数 /// public class HttpParam { private HttpVerb _httpVerb = HttpVerb.Get; private string _accpet; private string _userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.22 Safari/537.36"; /// /// 请求URL /// public string URL { get; set; } /// /// 请求参数 /// public object Parameters { get; set; } /// /// HttpVerb /// public HttpVerb Method { get { return _httpVerb; } set { _httpVerb = value; } } /// /// 设置或获取Post参数编码,默认UTF8Encoding(false) /// public Encoding Encoding { get; set; } /// /// 设置509证书集合 /// public X509CertificateCollection ClentCertificates { get; set; } /// /// 默认请求超时时间 /// public TimeSpan? Timeout { get; set; } /// /// 获取或设置 Accept HTTP 标头的值。 /// public string Accept { get { return _accpet; } set { _accpet = value; } } /// /// 获取或设置 Content-type HTTP 标头的值。 /// public string ContentType { get; set; } /// /// 获取或设置 Referer HTTP 标头的值。 /// public string Referer { get; set; } /// /// 获取或设置请求的代理信息 /// public IWebProxy Proxy { get; set; } = null; /// /// 获取或设置 User-agent HTTP 标头的值。 /// public string UserAgent { get { return _userAgent; } set { _userAgent = value; } } /// /// Cookie对象集合 /// public CookieCollection CookieCollection { get; set; } /// /// header对象 /// public WebHeaderCollection Header { get; set; } /// /// 回调验证 /// public RemoteCertificateValidationCallback RemoteCertificateValidationCallback { get; set; } } } }