Patches: Browse | Submit New | Admin

[#8127] ftp.rb raises an error that is not an FTPError on certain error conditions

Date:
2007-01-25 02:05
Priority:
3
Submitted By:
Daniel Martin (fizbin)
Assigned To:
Akinori MUSHA (knu)
Category:
Network / Comm / Protocols
State:
Open
Summary:
ftp.rb raises an error that is not an FTPError on certain error conditions

Detailed description
For more context, see ruby-talk:235896

If the server that ftp.rb is talking to unexpectedly closes the control connection in between responses, ftp.rb ends
up raising an EOFError.  This is highly confusing to the user, since any other server error generally causes an FTPError
(or one of its subclasses).

Specifically, if an ftp server is overloaded with open connections such that subsequent connection requests have it
accept the connection but immediately close it (this happens easily with inetd-based servers), then FTP.open will raise
EOFError.

This is very confusing, and I think it a bug.

Therefore, the definition of getline in ftp.rb should be:

    def getline
      begin
        line = @sock.readline # if get EOF, raise EOFError
      rescue EOFError
        raise FTPProtoError, "Connection closed unexpectedly"
      end
      line.sub!(/(\r\n|\n|\r)\z/n, "")
      if @debug_mode
        print "get: ", sanitize(line), "\n"
      end
      return line
    end
    private :getline

Instead of what it is now.

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-06-05 16:56
Sender: Roger Pack

I agree.
-Roger

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
assigned_tonone2007-06-13 06:30zenspider
category_idMisc / Other Standard Library2007-05-30 04:22zenspider
category_idNone2007-05-30 03:50zenspider