예제 #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));
        }