mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/net/ftp.rb (return_code): obsolete.
* lib/net/ftp.rb (last_response_code): new method. lastresp is now alias to last_response_code. * lib/net/ftp.rb (last_response): new method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
59b2d551e8
commit
1358ec597b
2 changed files with 37 additions and 26 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Thu Jul 31 00:17:19 2003 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/net/ftp.rb (return_code): obsolete.
|
||||||
|
|
||||||
|
* lib/net/ftp.rb (last_response_code): new method. lastresp is now
|
||||||
|
alias to last_response_code.
|
||||||
|
|
||||||
|
* lib/net/ftp.rb (last_response): new method.
|
||||||
|
|
||||||
Wed Jul 30 22:35:19 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
Wed Jul 30 22:35:19 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
* lib/mkmf.rb (dir_config): allow multiple directories separated
|
* lib/mkmf.rb (dir_config): allow multiple directories separated
|
||||||
|
|
|
@ -67,9 +67,6 @@ module Net
|
||||||
# When +true+, the connection is in passive mode. Default: false.
|
# When +true+, the connection is in passive mode. Default: false.
|
||||||
attr_accessor :passive
|
attr_accessor :passive
|
||||||
|
|
||||||
# The ASCII code used to separate lines.
|
|
||||||
attr_accessor :return_code
|
|
||||||
|
|
||||||
# When +true+, all traffic to and from the server is written
|
# When +true+, all traffic to and from the server is written
|
||||||
# to +$stdout+. Default: +false+.
|
# to +$stdout+. Default: +false+.
|
||||||
attr_accessor :debug_mode
|
attr_accessor :debug_mode
|
||||||
|
@ -81,8 +78,12 @@ module Net
|
||||||
# The server's welcome message.
|
# The server's welcome message.
|
||||||
attr_reader :welcome
|
attr_reader :welcome
|
||||||
|
|
||||||
|
# The server's last response code.
|
||||||
|
attr_reader :last_response_code
|
||||||
|
alias lastresp last_response_code
|
||||||
|
|
||||||
# The server's last response.
|
# The server's last response.
|
||||||
attr_reader :lastresp
|
attr_reader :last_response
|
||||||
|
|
||||||
#
|
#
|
||||||
# A synonym for +FTP.new+, but with a mandatory host parameter.
|
# A synonym for +FTP.new+, but with a mandatory host parameter.
|
||||||
|
@ -112,7 +113,6 @@ module Net
|
||||||
super()
|
super()
|
||||||
@binary = true
|
@binary = true
|
||||||
@passive = false
|
@passive = false
|
||||||
@return_code = "\n"
|
|
||||||
@debug_mode = false
|
@debug_mode = false
|
||||||
@resume = false
|
@resume = false
|
||||||
if host
|
if host
|
||||||
|
@ -123,6 +123,15 @@ module Net
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def return_code
|
||||||
|
$stderr.puts("warning: Net::FTP#return_code is obsolete and do nothing")
|
||||||
|
return "\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
def return_code=(s)
|
||||||
|
$stderr.puts("warning: Net::FTP#return_code= is obsolete and do nothing")
|
||||||
|
end
|
||||||
|
|
||||||
def open_socket(host, port)
|
def open_socket(host, port)
|
||||||
if defined? SOCKSsocket and ENV["SOCKS_SERVER"]
|
if defined? SOCKSsocket and ENV["SOCKS_SERVER"]
|
||||||
@passive = true
|
@passive = true
|
||||||
|
@ -181,12 +190,7 @@ module Net
|
||||||
|
|
||||||
def getline
|
def getline
|
||||||
line = @sock.readline # if get EOF, raise EOFError
|
line = @sock.readline # if get EOF, raise EOFError
|
||||||
if line[-2, 2] == CRLF
|
line.sub!(/(\r\n|\n|\r)\z/n, "")
|
||||||
line = line[0 .. -3]
|
|
||||||
elsif line[-1] == ?\r or
|
|
||||||
line[-1] == ?\n
|
|
||||||
line = line[0 .. -2]
|
|
||||||
end
|
|
||||||
if @debug_mode
|
if @debug_mode
|
||||||
print "get: ", sanitize(line), "\n"
|
print "get: ", sanitize(line), "\n"
|
||||||
end
|
end
|
||||||
|
@ -209,18 +213,17 @@ module Net
|
||||||
private :getmultiline
|
private :getmultiline
|
||||||
|
|
||||||
def getresp
|
def getresp
|
||||||
resp = getmultiline
|
@last_response = getmultiline
|
||||||
@lastresp = resp[0, 3]
|
@last_response_code = @last_response[0, 3]
|
||||||
c = resp[0]
|
case @last_response_code
|
||||||
case c
|
when /\A[123]/
|
||||||
when ?1, ?2, ?3
|
return @last_response
|
||||||
return resp
|
when /\A4/
|
||||||
when ?4
|
raise FTPTempError, @last_response
|
||||||
raise FTPTempError, resp
|
when /\A5/
|
||||||
when ?5
|
raise FTPPermError, @last_response
|
||||||
raise FTPPermError, resp
|
|
||||||
else
|
else
|
||||||
raise FTPProtoError, resp
|
raise FTPProtoError, @last_response
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private :getresp
|
private :getresp
|
||||||
|
@ -234,7 +237,7 @@ module Net
|
||||||
private :voidresp
|
private :voidresp
|
||||||
|
|
||||||
#
|
#
|
||||||
# WRITEME or make private
|
# Sends a command and returns the response.
|
||||||
#
|
#
|
||||||
def sendcmd(cmd)
|
def sendcmd(cmd)
|
||||||
synchronize do
|
synchronize do
|
||||||
|
@ -244,7 +247,7 @@ module Net
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# WRITEME or make private
|
# Sends a command and expect a response beginning with '2'.
|
||||||
#
|
#
|
||||||
def voidcmd(cmd)
|
def voidcmd(cmd)
|
||||||
synchronize do
|
synchronize do
|
||||||
|
@ -494,8 +497,7 @@ module Net
|
||||||
f = open(localfile, "w")
|
f = open(localfile, "w")
|
||||||
begin
|
begin
|
||||||
retrlines("RETR " + remotefile) do |line|
|
retrlines("RETR " + remotefile) do |line|
|
||||||
line = line + @return_code
|
f.puts(line)
|
||||||
f.write(line)
|
|
||||||
yield(line) if block
|
yield(line) if block
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
|
|
Loading…
Add table
Reference in a new issue