This project is read-only.

Invalid Server Reply :

Nov 7, 2011 at 8:37 AM

Hi Alessandro,

I've founded a potentially feature to do.

Since last Wenesday, my customer have modify his FTP server.

Now after a "LIST" Command, before the real response, the server send an empty response (no command number, is an empty string).  So the client catch the empty command, and thrown an exception(is normal) and ignore the real command thats is arrived too late (just after)

I think maybe we can modify the client to ignore the empty string, and create an event on the client to raise warnings like that.

I've download the source code, to try to modify the client. I'm not sure, how to operate to di this.

I thinks is in the "GetReply" Method of the "FTPSClient" Class.



Could you help me ?

Thanks by advance,

Regards,

Alexandre.

Nov 7, 2011 at 10:53 AM

I've modified the Function like that :

private FTPReply GetReply()
        {
            try
            {
                FTPReply reply = new FTPReply();
                bool replyDone = false;

                do
                {
                    string replyLine = ctrlSr.ReadLine();

                    if (replyLine == "")
                    {
                        replyLine = ctrlSr.ReadLine();
                    }
                    
                    Match m = Regex.Match(replyLine, @"^([0-9]{3})([\s\-])(.*)$");

                    if (m.Success)
                    {
                        int code = int.Parse(m.Groups[1].Value);
                        string messageLine = m.Groups[3].Value;
                        replyDone = (m.Groups[2].Value == " ");

                        if (reply.Code == 0)
                        {
                            reply.Code = code;
                            reply.Message = messageLine;
                        }
                        else // Multiline message
                        {
                            if (reply.Code != code)
                                throw new FTPReplyParseException(replyLine);

                            reply.Message += "\r\n" + messageLine;
                        }
                    }
                    else // Multiline message
                    {
                        if (reply.Code == 0)
                            throw new FTPReplyParseException(replyLine);

                        reply.Message += "\r\n" + replyLine.TrimStart();
                    }
                }
                while (!replyDone);

                waitingCompletionReply = (reply.Code < 200);

                if (LogServerReply != null)
                    LogServerReply(this, new LogServerReplyEventArgs(reply));

                if (reply.Code >= 400)
                    throw new FTPCommandException(reply);

                return reply;
            }
            catch (Exception)
            {
                waitingCompletionReply = false;
                throw;
            }
        }

I've to add an event to raise Warning.