Пример #1
0
        static void TestUri(RequestMethod method, string uri, string postData)
        {
            var requestSetting = new RequestSetting(method, uri);
            requestSetting.PostData = Encoding.UTF8.GetBytes(postData);
            var requestState = new RequestState();
            requestState.Setting = requestSetting;
            requestState.Completed += new EventHandler<RequestCompeleteEventArgs>(RequestCompleted);

            var request = new Request();
            request.Send(requestState);
        }
Пример #2
0
        void SetHttpRequest(RequestSetting setting)
        {
            InitHttpRequest(setting.Url);

            // 验证证书
            SetCerList(setting.ClientCertificates);
            SetCer(setting.CerPath);

            // 设置代理
            SetProxy(setting.ProxyIp, setting.ProxyPort, setting.ProxyUserName, setting.ProxyPwd);

            //设置RequestMethod
            SetMethod(setting.Method);
            request.ProtocolVersion = setting.ProtocolVersion;

            request.Accept = setting.Accept;
            request.UserAgent = setting.UserAgent;
            request.Referer = setting.Referer;

            //设置Cookie
            SetCookie(setting.Cookie, setting.CookieCollection);
            //设置自定义头
            SetHeaders(setting.Headers);

            request.ReadWriteTimeout = setting.ReadWriteTimeout;
            request.Timeout = setting.Timeout;
            request.AllowAutoRedirect = setting.AllowAutoRedirect;

            SetContentType(setting.ContentType);
        }
Пример #3
0
        static void TestUri(RequestMethod method, string uri)
        {
            var requestSetting = new RequestSetting(method, uri);
            var requestState = new RequestState();
            requestState.Setting = requestSetting;
            requestState.Completed += new EventHandler<RequestCompeleteEventArgs>(RequestCompleted);

            var request = new Request();
            request.Send(requestState);
        }