예제 #1
0
 private void EndGetResponse(IAsyncResult ar, WebStreams state)
 {
     state.Response     = (HttpWebResponse)state.Request.EndGetResponse(ar);
     state.StreamReader = state.Response.GetResponseStream();
     if (state.StreamReader != null)
     {
         state.StreamReader.BeginRead(state.Buffer, 0, state.Buffer.Length, __EndReadResponse, state);
     }
 }
예제 #2
0
        private void BeginGetResponse(WebStreams requestState)
        {
            requestState.Dispose();
            var state = new WebStreams {
                StreamWriter = new MemoryStream(), Request = requestState.Request
            };
            var ar = state.Request.BeginGetResponse(__EndGetResponse, state);

            ThreadPool.RegisterWaitForSingleObject(ar.AsyncWaitHandle, Je.web.TimeoutCallback, state.Request, Je.web.RequestTimeout, true);
        }
예제 #3
0
        private void EndReadResponse(IAsyncResult ar, WebStreams state)
        {
            var read = state.StreamReader.EndRead(ar);

            if (read > 0)
            {
                state.StreamWriter.BeginWrite(state.Buffer, 0, read, __EndWriteMemory, state);
            }
            else
            {
                CommandThreads.Run(() => Completing(state));
            }
        }
예제 #4
0
        private void EndReadRequestMemory(IAsyncResult ar, WebStreams state)
        {
            var read = state.StreamReader.EndRead(ar);

            if (read > 0)
            {
                state.StreamWriter.BeginWrite(state.Buffer, 0, read, __EndWriteRequestStream, state);
            }
            else
            {
                BeginGetResponse(state);
            }
        }
예제 #5
0
        private WebStreams BeginGetRequestStream()
        {
            var state = new WebStreams();

            state.Request      = CreateRequest();
            state.StreamReader = Je.bin.ObjToMem(Value, Je.web.WebEncoding);
            if (state.StreamReader.Length == 0)
            {
                BeginGetResponse(state);
                return(state);
            }
            state.Request.ContentLength = state.StreamReader.Length;
            state.Request.BeginGetRequestStream(__EndGetRequestStream, state);
            return(state);
        }
예제 #6
0
 private void Completing(WebStreams state)
 {
     try
     {
         var ms = state.StreamWriter as MemoryStream;
         if (ms != null)
         {
             Result = Je.bin.MemToObj <TResult>(ms, Je.web.WebEncoding);
         }
         state.Dispose();
         EndExecuteEvent(Je.cmd.EmptyEventArgs(this));
     }
     catch (Exception e)
     {
         state.Dispose();
         Finalize(e);
     }
 }
예제 #7
0
 private void EndWriteMemory(IAsyncResult ar, WebStreams state)
 {
     state.StreamWriter.EndWrite(ar);
     state.Reset();
     state.StreamReader.BeginRead(state.Buffer, 0, state.Buffer.Length, __EndReadResponse, state);
 }
예제 #8
0
 private void EndGetRequestStream(IAsyncResult ar, WebStreams state)
 {
     state.StreamWriter = state.Request.EndGetRequestStream(ar);
     state.StreamReader.BeginRead(state.Buffer, 0, state.Buffer.Length, __EndReadRequestMemory, state);
 }