--cWoXeonUoKmBZSoM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
This patch applies to the Net::FTP class that comes with Ruby 1.8.5.
When an FTP server severs the data connection (e.g. when a user exceeds
their quota), Net::FTP will raise Errno::EPIPE. While this may be
correct, I would prefer it to check the control connection for a
response first, as the server may have sent a reason for severing the
data connection.
This patch makes Net::FTP check for a response, after catching
Errno::EPIPE. If getresp sees a problem with the response (e.g. it has
a 4XX or 5XX code), getresp will raise an exception. If it doesn't,
this re-raises the original Errno::EPIPE.
I couldn't find an appropriate place to make this change just once.
That, it would seem, would require a fair amount of refactoring (i.e.
merging the sending of ASCII and binary data).
If anyone has any comments on the patch, please let me know.
Regards,
--
Simon Williams
--cWoXeonUoKmBZSoM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ftp.rb.epipe.patch"
--- net/ftp.rb.orig 2004-06-22 08:47:35.000000000 +0100
+++ net/ftp.rb 2006-11-15 13:27:40.000000000 +0000
@@ -456,6 +456,13 @@
conn.close
voidresp
end
+ rescue Errno::EPIPE
+ # EPIPE, in this case, means that the data connection was unexpectedly
+ # terminated. Rather than just raising EPIPE to the caller, check the
+ # response on the control connection. If getresp doesn't raise a more
+ # appropriate exception, re-raise the original exception.
+ getresp
+ raise
end
#
@@ -480,6 +487,13 @@
conn.close
voidresp
end
+ rescue Errno::EPIPE
+ # EPIPE, in this case, means that the data connection was unexpectedly
+ # terminated. Rather than just raising EPIPE to the caller, check the
+ # response on the control connection. If getresp doesn't raise a more
+ # appropriate exception, re-raise the original exception.
+ getresp
+ raise
end
#
--cWoXeonUoKmBZSoM--