Пример #1
0
        internal HttpFormResponse Post(HttpFormGetRequest postRequest, string rawData)
        {
            WebRequest request = CreateRequest(postRequest.Url, postRequest.UserName, postRequest.Password, postRequest.ContentType, postRequest.Headers, postRequest.Cookies, true);

            PreapreRequestToPost(request, rawData);

            return(ReadResponse(request));
        }
Пример #2
0
        public void GetAsync(HttpFormGetRequest getRequest, Action <HttpFormResponse> onComplete, Action <Exception> onError)
        {
            WebRequest request = CreateRequest(getRequest.Url, getRequest.UserName, getRequest.Password, getRequest.ContentType, getRequest.Headers, getRequest.Cookies, false);

            try
            {
                request.BeginGetResponse(ResponseCallback, new StateContainer {
                    Request = request, OnComplete = onComplete, OnError = onError
                });
            }
            catch (Exception e)
            {
                if (onError != null)
                {
                    onError(e);
                }
            }
        }
Пример #3
0
        internal void PostAsync(HttpFormGetRequest postRequest, string rawData, Action <HttpFormResponse> onComplete, Action <Exception> onError)
        {
            WebRequest request = CreateRequest(postRequest.Url, postRequest.UserName, postRequest.Password, postRequest.ContentType, postRequest.Headers, postRequest.Cookies, true);

            byte[] content = Encoding.ASCII.GetBytes(rawData);
            request.ContentLength = content.Length;

            try
            {
                request.BeginGetRequestStream(RequestCallback, new StateContainer {
                    Request = request, RequestContent = content, OnComplete = onComplete, OnError = onError
                });
            }
            catch (Exception e)
            {
                if (onError != null)
                {
                    onError(e);
                }
            }
        }
Пример #4
0
 public void GetAsync(HttpFormGetRequest getRequest)
 {
     GetAsync(getRequest, null, null);
 }
Пример #5
0
        public HttpFormResponse Get(HttpFormGetRequest getRequest)
        {
            WebRequest request = CreateRequest(getRequest.Url, getRequest.UserName, getRequest.Password, getRequest.ContentType, getRequest.Headers, getRequest.Cookies, false);

            return(ReadResponse(request));
        }