예제 #1
0
        private void ReadCallBack(IAsyncResult ar)
        {
            if (_disposed)
            {
                return;
            }
            if (_state == ClientState.ReadingProlog && Server.State != HttpServerState.Started)
            {
                Dispose();
                return;
            }
            try
            {
                ReadBuffer.EndRead(_stream, ar);
            }
            catch (ObjectDisposedException)
            {
                Dispose();
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }

            if (ReadBuffer.DataAvailable)
            {
                ProcessReadBuffer();
            }
            else
            {
                Dispose();
            }
        }
예제 #2
0
        private void ReadCallback(IAsyncResult asyncResult)
        {
            if (_disposed)
            {
                return;
            }
            if (_state == ClientState.ReadingProlog && Server.State != HttpServerState.Started)
            {
                Dispose();
                return;
            }

            try
            {
                ReadBuffer.EndRead(_stream, asyncResult);
                if (ReadBuffer.DataAvailable)
                {
                    ProcessReadBuffer();
                }
                else
                {
                    Dispose();
                }
            }
            catch (ObjectDisposedException)
            {
                Console.WriteLine("** HttpClient Exception | Failed to read");
                Dispose();
            }
            catch (Exception ex)
            {
                Console.WriteLine("** HttpClient Exception | Failed to read from the HTTP connection");
                ProcessException(ex);
            }
        }
예제 #3
0
        private void ReadCallback(IAsyncResult asyncResult)
        {
            if (_disposed)
            {
                return;
            }
            if (_state == ClientState.STATE.READING_PROLOG && Server.State != HTTPServerState.STATE.STARTED)
            {
                Dispose();
                return;
            }

            try
            {
                ReadBuffer.EndRead(_stream, asyncResult);
                if (ReadBuffer.DataAvailable)
                {
                    ProcessReadBuffer();
                }
                else
                {
                    Dispose();
                }
            }
            catch (ObjectDisposedException)
            {
                Dispose();
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
예제 #4
0
        private void ReadCallback(IAsyncResult asyncResult)
        {
            if (_disposed)
            {
                return;
            }

            // The below state matches the RequestClose state. Dispose immediately
            // when this occurs.

            if (
                _state == ClientState.ReadingProlog &&
                Server.State != HttpServerState.Started
                )
            {
                Dispose();
                return;
            }

            try
            {
                ReadBuffer.EndRead(_stream, asyncResult);

                if (ReadBuffer.DataAvailable)
                {
                    ProcessReadBuffer();
                }
                else
                {
                    Dispose();
                }
            }
            catch (ObjectDisposedException ex)
            {
                Log.Info("Failed to read", ex);

                Dispose();
            }
            catch (Exception ex)
            {
                Log.Info("Failed to read from the HTTP connection", ex);

                ProcessException(ex);
            }
        }
예제 #5
0
 /// <summary>
 /// Processa a chamada de retorno da leitura.
 /// </summary>
 /// <param name="asyncResult"></param>
 private void ReadCallback(IAsyncResult asyncResult)
 {
     if (_disposed)
     {
         return;
     }
     if (_state == ClientState.ReadingProlog)
     {
         Dispose();
         return;
     }
     try
     {
         ReadBuffer.EndRead(_stream, asyncResult);
         if (ReadBuffer.DataAvailable)
         {
             ProcessReadBuffer();
         }
         else
         {
             if (InputStream != null)
             {
                 InputStream.Seek(0, SeekOrigin.Begin);
             }
             if (!_writeOutput)
             {
                 ExecuteRequest();
             }
             else
             {
                 Dispose();
             }
         }
     }
     catch (ObjectDisposedException)
     {
         Dispose();
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }