public void Send()
        {
            HttpRequestState requestState = new HttpRequestState();

            requestState.Request = webRequest;

            if (requestBytes != null)
            {
                webRequest.BeginGetRequestStream(RequestStreamData, requestState);
            }
            else
            {
                webRequest.BeginGetResponse(ReceivedData, requestState);
            }
        }
        private void RequestStreamData(IAsyncResult asyncResult)
        {
            try
            {
                HttpRequestState          requestState   = (HttpRequestState)asyncResult.AsyncState;
                System.Net.HttpWebRequest httpWebRequest = requestState.Request;

                var stream = httpWebRequest.EndGetRequestStream(asyncResult);
                stream.Write(requestBytes, 0, requestBytes.Length);
                stream.Close();

                webRequest.BeginGetResponse(ReceivedData, requestState);
            }
            catch (Exception ex)
            {
                error        = ex.Message;
                isDone       = true;
                isError      = true;
                responseCode = 0;
            }
        }
        private void ReceivedData(IAsyncResult asyncResult)
        {
            try
            {
                HttpRequestState requestState = (HttpRequestState)asyncResult.AsyncState;

                System.Net.HttpWebRequest httpWebRequest = requestState.Request;

                requestState.Response = (HttpWebResponse)httpWebRequest.EndGetResponse(asyncResult);
                Stream responseStream = requestState.Response.GetResponseStream();
                requestState.StreamResponse = responseStream;

                responseStream.BeginRead(requestState.BufferRead, 0, HttpRequestState.BUFFER_SIZE, new AsyncCallback(ReadCallBack), requestState);
            }catch (Exception ex)
            {
                error        = ex.Message;
                isDone       = true;
                isError      = true;
                responseCode = 0;
            }
        }
        private void ReadCallBack(IAsyncResult asyncResult)
        {
            try
            {
                HttpRequestState requestState   = (HttpRequestState)asyncResult.AsyncState;
                Stream           responseStream = requestState.StreamResponse;
                int read = responseStream.EndRead(asyncResult);

                if (read > 0)
                {
                    responseLst.AddRange(requestState.BufferRead);
                    responseStream.BeginRead(requestState.BufferRead, 0, HttpRequestState.BUFFER_SIZE, new AsyncCallback(ReadCallBack), requestState);
                }
                else
                {
                    responseCode  = (int)requestState.Response.StatusCode;
                    responseBytes = responseLst.ToArray();
                    responseLst.Clear();
                    responseLst = null;
                    isDone      = true;
                    isError     = false;
                    if (responseCode < 200 || responseCode >= 300)
                    {
                        isError = true;
                    }
                    responseStream.Close();
                }
            }
            catch (Exception ex)
            {
                error        = ex.Message;
                isDone       = true;
                isError      = true;
                responseCode = 0;
            }
        }
        public void Send()
        {
            HttpRequestState requestState = new HttpRequestState();
            requestState.Request = webRequest;

            if (requestBytes != null)
            {
                webRequest.BeginGetRequestStream(RequestStreamData, requestState);
            }else
            {
                webRequest.BeginGetResponse(ReceivedData, requestState);
            }
        }