Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/net/ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def transfercmd(cmd, rest_offset = nil) # :nodoc:
raise FTPReplyError, resp
end
conn, = sock.accept
sock.shutdown(Socket::SHUT_WR) rescue nil
sock.close_write rescue nil
sock.read rescue nil
ensure
sock.close
Expand Down Expand Up @@ -671,7 +671,7 @@ def retrbinary(cmd, blocksize, rest_offset = nil) # :yield: data
while data = conn.read(blocksize)
yield(data)
end
conn.shutdown(Socket::SHUT_WR) rescue nil
conn.close_write rescue nil
conn.read_timeout = 1
conn.read rescue nil
ensure
Expand All @@ -696,7 +696,7 @@ def retrlines(cmd) # :yield: line
while line = conn.gets
yield(line.sub(/\r?\n\z/, ""), !line.match(/\n\z/).nil?)
end
conn.shutdown(Socket::SHUT_WR) rescue nil
conn.close_write rescue nil
conn.read_timeout = 1
conn.read rescue nil
ensure
Expand Down Expand Up @@ -725,7 +725,7 @@ def storbinary(cmd, file, blocksize, rest_offset = nil) # :yield: data
conn.write(buf)
yield(buf) if block_given?
end
conn.shutdown(Socket::SHUT_WR) rescue nil
conn.close_write rescue nil
conn.read_timeout = 1
conn.read rescue nil
ensure
Expand Down Expand Up @@ -761,7 +761,7 @@ def storlines(cmd, file) # :yield: line
conn.write(buf)
yield(buf) if block_given?
end
conn.shutdown(Socket::SHUT_WR) rescue nil
conn.close_write rescue nil
conn.read_timeout = 1
conn.read rescue nil
ensure
Expand Down Expand Up @@ -1397,7 +1397,7 @@ def option(name, params = nil)
def close
if @sock and not @sock.closed?
begin
@sock.shutdown(Socket::SHUT_WR) rescue nil
@sock.close_write rescue nil
orig, self.read_timeout = self.read_timeout, 3
@sock.read rescue nil
ensure
Expand Down Expand Up @@ -1507,7 +1507,7 @@ def method_missing(mid, *args)
end

class BufferedSocket < BufferedIO
[:local_address, :remote_address, :addr, :peeraddr, :send, :shutdown].each do |method|
[:local_address, :remote_address, :addr, :peeraddr, :send, :close_write].each do |method|
define_method(method) { |*args|
@io.__send__(method, *args)
}
Expand Down Expand Up @@ -1544,10 +1544,10 @@ def readline
if defined?(OpenSSL::SSL::SSLSocket)
class BufferedSSLSocket < BufferedSocket

def shutdown(*args)
def close_write
# Invokes SSL_shutdown, which sends a close_notify message to the peer.
@io.__send__(:stop)
end
end if OpenSSL::VERSION < "3.3" # openssl 3.3 = Ruby 3.4

def send(mesg, flags, dest = nil)
# Ignore flags and dest.
Expand Down
Loading