예제 #1
0
 override internal void OnNewResponseLine(FtpResponse ctx, FtpResponseLine line)
 {
     if (FtpResponseLineType.Single == line.Type)
     {
         if (line.Code != ctx.Code)                //first code and the last should be the equal
         {
             ctx.ChangeState(new FtpResponseFormatError());
             //throw new FtpResponseFormatException("First and last line reply codes is not equals.", ctx.CurrentLineNumber);
             throw new FtpProtocolException("First and last line response's codes are not equals.", null, -1, -1);
         }
         else
         {
             ctx.ChangeState(new FtpResponseCompleted());
         }
     }
     else if (FtpResponseLineType.Intermediate == line.Type)
     {
         //noop
     }
     else if (FtpResponseLineType.First == line.Type)
     {
         //noop
     }
     else
     {
         ctx.ChangeState(new FtpResponseFormatError());
         throw new FtpProtocolException("Unexpected response line received.", null, -1, -1);
     }
 }
예제 #2
0
 void OnNewResponseLine(FtpResponseLine line)
 {
     _current.OnNewResponseLine(this, line);
     if (NewLineEvent != null)
     {
         NewLineEvent(this, line);
     }
 }
예제 #3
0
 override internal void OnNewResponseLine(FtpResponse ctx, FtpResponseLine line)
 {
     if (FtpResponseLineType.Single == line.Type)
     {
         ctx.ChangeState(new FtpResponseCompleted());
     }
     else if (FtpResponseLineType.First == line.Type)
     {
         ctx.ChangeState(new FtpResponseIntermediate());
     }
     else
     {
         ctx.ChangeState(new FtpResponseFormatError());
         throw new FtpProtocolException("Unexpected response line received.", null, -1, -1);
         //throw new FtpResponseFormatException("Unexpected respone line received.", ctx.CurrentLineNumber);
     }
 }
예제 #4
0
        internal void PutLine(LineInfo lineInfo)
        {
            if (null == lineInfo)
            {
                throw new ArgumentNullException("lineInfo", "Value cannot be null.");
            }

            _rawData.Add(lineInfo.Content);

            FtpResponseLine line = new FtpResponseLine(lineInfo);

            if (null == _lines)
            {
                _lines = new ArrayList();
            }
            _lines.Add(line);
            try
            {
                _current.OnNewResponseLine(this, line);
            }
            catch (FtpProtocolException e)
            {
                NSTrace.WriteLineError("Protocol error: " + e.ToString());
                e.SetResponse(this);
                e.SetLine(_lines.Count - 1);
                throw;
            }

            if (FtpResponseState.Completed == State)
            {
                OnCompleted();
            }
            else if (FtpResponseState.Intermediate != State)
            {
                string msg = string.Format("Response object is in invalid state: {0}. Stack: {1}.", State.ToString(), Environment.StackTrace);
                NSTrace.WriteLineError(msg);
                throw new InvalidOperationException(msg);
            }
        }
예제 #5
0
 abstract internal void OnNewResponseLine(FtpResponse ctx, FtpResponseLine line);
예제 #6
0
 override internal void OnNewResponseLine(FtpResponse ctx, FtpResponseLine line)
 {
     throw new InvalidOperationException("Invalid response can't be modified");
 }