System.Net.CommandStream.PostReadCommandProcessing C# (CSharp) Method

PostReadCommandProcessing() private method

private PostReadCommandProcessing ( Stream &stream ) : bool
stream Stream
return bool
        private bool PostReadCommandProcessing(ref Stream stream)
        {
            if (_index >= _commands.Length)
                return false;

            // Set up front to prevent a race condition on result == PipelineInstruction.Pause
            _doSend = false;
            _doRead = false;

            PipelineInstruction result;
            PipelineEntry entry;
            if (_index == -1)
                entry = null;
            else
                entry = _commands[_index];

            // Final QUIT command may get exceptions since the connection 
            // may be already closed by the server. So there is no response 
            // to process, just advance the pipeline to continue.
            if (_currentResponseDescription == null && entry.Command == "QUIT\r\n")
                result = PipelineInstruction.Advance;
            else
                result = PipelineCallback(entry, _currentResponseDescription, false, ref stream);

            if (result == PipelineInstruction.Abort)
            {
                Exception exception;
                if (_abortReason != string.Empty)
                    exception = new WebException(_abortReason);
                else
                    exception = GenerateException(SR.net_ftp_protocolerror, WebExceptionStatus.ServerProtocolViolation, null);
                Abort(exception);
                throw exception;
            }
            else if (result == PipelineInstruction.Advance)
            {
                _currentResponseDescription = null;
                _doSend = true;
                _doRead = true;
                _index++;
            }
            else if (result == PipelineInstruction.Pause)
            {
                // PipelineCallback did an async operation and will have to re-enter again.
                // Hold on for now.
                return true;
            }
            else if (result == PipelineInstruction.GiveStream)
            {
                // We will have another response coming, don't send
                _currentResponseDescription = null;
                _doRead = true;
                if (_isAsync)
                {
                    // If they block in the requestcallback we should still continue the pipeline
                    ContinueCommandPipeline();
                    InvokeRequestCallback(stream);
                }
                return true;
            }
            else if (result == PipelineInstruction.Reread)
            {
                // Another response is expected after this one
                _currentResponseDescription = null;
                _doRead = true;
            }
            return false;
        }