aboutsummaryrefslogtreecommitdiffstats
path: root/lib/net
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-06 03:56:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-06 03:56:38 +0000
commit287a34ae0dfc23e4158f67cb7783d239f202c368 (patch)
tree5e35d5b41aae961b37cf6632f60c42f51c7aa775 /lib/net
parent9b52ae2e6491bb5d6c59e1799449f6268baf6f89 (diff)
downloadruby-287a34ae0dfc23e4158f67cb7783d239f202c368.tar.gz
* {ext,lib,test}/**/*.rb: removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net')
-rw-r--r--lib/net/ftp.rb120
-rw-r--r--lib/net/http.rb208
-rw-r--r--lib/net/https.rb2
-rw-r--r--lib/net/imap.rb370
-rw-r--r--lib/net/pop.rb102
-rw-r--r--lib/net/protocol.rb4
-rw-r--r--lib/net/smtp.rb110
-rw-r--r--lib/net/telnet.rb206
8 files changed, 561 insertions, 561 deletions
diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb
index 06cc3eafa2..40227b69d8 100644
--- a/lib/net/ftp.rb
+++ b/lib/net/ftp.rb
@@ -1,11 +1,11 @@
-#
+#
# = net/ftp.rb - FTP Client Library
-#
+#
# Written by Shugo Maeda <shugo@ruby-lang.org>.
#
# Documentation by Gavin Sinclair, sourced from "Programming Ruby" (Hunt/Thomas)
# and "Ruby In a Nutshell" (Matsumoto), used with permission.
-#
+#
# This library is distributed under the terms of the Ruby license.
# You can freely distribute/modify this library.
#
@@ -22,8 +22,8 @@ module Net
# :stopdoc:
class FTPError < StandardError; end
class FTPReplyError < FTPError; end
- class FTPTempError < FTPError; end
- class FTPPermError < FTPError; end
+ class FTPTempError < FTPError; end
+ class FTPPermError < FTPError; end
class FTPProtoError < FTPError; end
# :startdoc:
@@ -34,11 +34,11 @@ module Net
# advantage of Ruby's style and strengths.
#
# == Example
- #
+ #
# require 'net/ftp'
#
# === Example 1
- #
+ #
# ftp = Net::FTP.new('ftp.netlab.co.jp')
# ftp.login
# files = ftp.chdir('pub/lang/ruby/contrib')
@@ -71,13 +71,13 @@ module Net
#
class FTP
include MonitorMixin
-
+
# :stopdoc:
FTP_PORT = 21
CRLF = "\r\n"
DEFAULT_BLOCKSIZE = 4096
# :startdoc:
-
+
# When +true+, transfers are performed in binary mode. Default: +true+.
attr_reader :binary
@@ -101,7 +101,7 @@ module Net
# The server's last response.
attr_reader :last_response
-
+
#
# A synonym for <tt>FTP.new</tt>, but with a mandatory host parameter.
#
@@ -120,7 +120,7 @@ module Net
new(host, user, passwd, acct)
end
end
-
+
#
# Creates and returns a new +FTP+ object. If a +host+ is given, a connection
# is made. Additionally, if the +user+ is given, the given user name,
@@ -178,7 +178,7 @@ module Net
end
end
private :open_socket
-
+
#
# Establishes an FTP connection to host, optionally overriding the default
# port. If the environment variable +SOCKS_SERVER+ is set, sets up the
@@ -215,7 +215,7 @@ module Net
end
end
private :sanitize
-
+
def putline(line)
if @debug_mode
print "put: ", sanitize(line), "\n"
@@ -224,7 +224,7 @@ module Net
@sock.write(line)
end
private :putline
-
+
def getline
line = @sock.readline # if get EOF, raise EOFError
line.sub!(/(\r\n|\n|\r)\z/n, "")
@@ -234,7 +234,7 @@ module Net
return line
end
private :getline
-
+
def getmultiline
line = getline
buff = line
@@ -248,7 +248,7 @@ module Net
return buff << "\n"
end
private :getmultiline
-
+
def getresp
@last_response = getmultiline
@last_response_code = @last_response[0, 3]
@@ -264,7 +264,7 @@ module Net
end
end
private :getresp
-
+
def voidresp
resp = getresp
if resp[0] != ?2
@@ -272,7 +272,7 @@ module Net
end
end
private :voidresp
-
+
#
# Sends a command and returns the response.
#
@@ -282,7 +282,7 @@ module Net
return getresp
end
end
-
+
#
# Sends a command and expect a response beginning with '2'.
#
@@ -292,7 +292,7 @@ module Net
voidresp
end
end
-
+
def sendport(host, port)
af = (@sock.peeraddr)[0]
if af == "AF_INET"
@@ -305,7 +305,7 @@ module Net
voidcmd(cmd)
end
private :sendport
-
+
def makeport
sock = TCPServer.open(@sock.addr[3], 0)
port = sock.addr[1]
@@ -314,7 +314,7 @@ module Net
return sock
end
private :makeport
-
+
def makepasv
if @sock.peeraddr[0] == "AF_INET"
host, port = parse227(sendcmd("PASV"))
@@ -325,13 +325,13 @@ module Net
return host, port
end
private :makepasv
-
+
def transfercmd(cmd, rest_offset = nil)
if @passive
host, port = makepasv
conn = open_socket(host, port)
if @resume and rest_offset
- resp = sendcmd("REST " + rest_offset.to_s)
+ resp = sendcmd("REST " + rest_offset.to_s)
if resp[0] != ?3
raise FTPReplyError, resp
end
@@ -345,7 +345,7 @@ module Net
else
sock = makeport
if @resume and rest_offset
- resp = sendcmd("REST " + rest_offset.to_s)
+ resp = sendcmd("REST " + rest_offset.to_s)
if resp[0] != ?3
raise FTPReplyError, resp
end
@@ -362,7 +362,7 @@ module Net
return conn
end
private :transfercmd
-
+
def getaddress
thishost = Socket.gethostname
if not thishost.index(".")
@@ -378,7 +378,7 @@ module Net
return realuser + "@" + thishost
end
private :getaddress
-
+
#
# Logs in to the remote host. The session must have been previously
# connected. If +user+ is the string "anonymous" and the +password+ is
@@ -391,7 +391,7 @@ module Net
if user == "anonymous" and passwd == nil
passwd = getaddress
end
-
+
resp = ""
synchronize do
resp = sendcmd('USER ' + user)
@@ -410,7 +410,7 @@ module Net
@welcome = resp
self.binary = true
end
-
+
#
# Puts the connection into binary (image) mode, issues the given command,
# and fetches the data returned, passing it to the associated block in
@@ -431,7 +431,7 @@ module Net
end
end
end
-
+
#
# Puts the connection into ASCII (text) mode, issues the given command, and
# passes the resulting data, one line at a time, to the associated block. If
@@ -457,7 +457,7 @@ module Net
end
end
end
-
+
#
# Puts the connection into binary (image) mode, issues the given server-side
# command (such as "STOR myfile"), and sends the contents of the file named
@@ -489,7 +489,7 @@ module Net
getresp
raise
end
-
+
#
# Puts the connection into ASCII (text) mode, issues the given server-side
# command (such as "STOR myfile"), and sends the contents of the file
@@ -554,7 +554,7 @@ module Net
f.close if localfile
end
end
-
+
#
# Retrieves +remotefile+ in ASCII (text) mode, storing the result in
# +localfile+.
@@ -593,7 +593,7 @@ module Net
gettextfile(remotefile, localfile, &block)
end
end
-
+
#
# Transfers +localfile+ to the server in binary mode, storing the result in
# +remotefile+. If a block is supplied, calls it, passing in the transmitted
@@ -618,7 +618,7 @@ module Net
f.close
end
end
-
+
#
# Transfers +localfile+ to the server in ASCII (text) mode, storing the result
# in +remotefile+. If callback or an associated block is supplied, calls it,
@@ -653,7 +653,7 @@ module Net
cmd = "ACCT " + account
voidcmd(cmd)
end
-
+
#
# Returns an array of filenames in the remote directory.
#
@@ -668,7 +668,7 @@ module Net
end
return files
end
-
+
#
# Returns an array of file information in the directory (the output is like
# `ls -l`). If a block is given, it iterates through the listing.
@@ -690,7 +690,7 @@ module Net
end
alias ls list
alias dir list
-
+
#
# Renames a file on the server.
#
@@ -701,7 +701,7 @@ module Net
end
voidcmd("RNTO " + toname)
end
-
+
#
# Deletes a file on the server.
#
@@ -715,7 +715,7 @@ module Net
raise FTPReplyError, resp
end
end
-
+
#
# Changes the (remote) directory.
#
@@ -733,22 +733,22 @@ module Net
cmd = "CWD " + dirname
voidcmd(cmd)
end
-
+
#
# Returns the size of the given (remote) filename.
#
def size(filename)
with_binary(true) do
resp = sendcmd("SIZE " + filename)
- if resp[0, 3] != "213"
+ if resp[0, 3] != "213"
raise FTPReplyError, resp
end
return resp[3..-1].strip.to_i
end
end
-
+
MDTM_REGEXP = /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/ # :nodoc:
-
+
#
# Returns the last modification time of the (remote) file. If +local+ is
# +true+, it is returned as a local time, otherwise it's a UTC time.
@@ -758,7 +758,7 @@ module Net
ary = str.scan(MDTM_REGEXP)[0].collect {|i| i.to_i}
return local ? Time.local(*ary) : Time.gm(*ary)
end
-
+
#
# Creates a remote directory.
#
@@ -766,14 +766,14 @@ module Net
resp = sendcmd("MKD " + dirname)
return parse257(resp)
end
-
+
#
# Removes a remote directory.
#
def rmdir(dirname)
voidcmd("RMD " + dirname)
end
-
+
#
# Returns the current remote directory.
#
@@ -782,7 +782,7 @@ module Net
return parse257(resp)
end
alias getdir pwd
-
+
#
# Returns system information.
#
@@ -793,7 +793,7 @@ module Net
end
return resp[4 .. -1]
end
-
+
#
# Aborts the previous command (ABOR command).
#
@@ -807,7 +807,7 @@ module Net
end
return resp
end
-
+
#
# Returns the status (STAT command).
#
@@ -817,7 +817,7 @@ module Net
@sock.send(line, Socket::MSG_OOB)
return getresp
end
-
+
#
# Issues the MDTM command. TODO: more info.
#
@@ -827,7 +827,7 @@ module Net
return resp[3 .. -1].strip
end
end
-
+
#
# Issues the HELP command.
#
@@ -838,7 +838,7 @@ module Net
end
sendcmd(cmd)
end
-
+
#
# Exits the FTP session.
#
@@ -860,7 +860,7 @@ module Net
cmd = "SITE " + arg
voidcmd(cmd)
end
-
+
#
# Closes the connection. Further operations are impossible until you open
# a new connection with #connect.
@@ -868,14 +868,14 @@ module Net
def close
@sock.close if @sock and not @sock.closed?
end
-
+
#
# Returns +true+ iff the connection is closed.
#
def closed?
@sock == nil or @sock.closed?
end
-
+
def parse227(resp)
if resp[0, 3] != "227"
raise FTPReplyError, resp
@@ -894,7 +894,7 @@ module Net
return host, port
end
private :parse227
-
+
def parse228(resp)
if resp[0, 3] != "228"
raise FTPReplyError, resp
@@ -922,11 +922,11 @@ module Net
end
host = v6[0, 8].join(":")
port = (numbers[19].to_i << 8) + numbers[20].to_i
- end
+ end
return host, port
end
private :parse228
-
+
def parse229(resp)
if resp[0, 3] != "229"
raise FTPReplyError, resp
@@ -945,7 +945,7 @@ module Net
return host, port
end
private :parse229
-
+
def parse257(resp)
if resp[0, 3] != "257"
raise FTPReplyError, resp
diff --git a/lib/net/http.rb b/lib/net/http.rb
index e3716b1bde..d95615f5c8 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -4,26 +4,26 @@
# Copyright (c) 1999-2007 Yukihiro Matsumoto
# Copyright (c) 1999-2007 Minero Aoki
# Copyright (c) 2001 GOTOU Yuuzou
-#
+#
# Written and maintained by Minero Aoki <aamine@loveruby.net>.
# HTTPS support added by GOTOU Yuuzou <gotoyuzo@notwork.org>.
#
# This file is derived from "http-access.rb".
#
# Documented by Minero Aoki; converted to RDoc by William Webber.
-#
+#
# This program is free software. You can re-distribute and/or
# modify this program under the same terms of ruby itself ---
# Ruby Distribution License or GNU General Public License.
#
-# See Net::HTTP for an overview and examples.
-#
+# See Net::HTTP for an overview and examples.
+#
# NOTE: You can find Japanese version of this document here:
# http://www.ruby-lang.org/ja/man/html/net_http.html
-#
+#
#--
# $Id$
-#++
+#++
require 'net/protocol'
require 'uri'
@@ -36,29 +36,29 @@ module Net #:nodoc:
# :startdoc:
# == What Is This Library?
- #
+ #
# This library provides your program functions to access WWW
# documents via HTTP, Hyper Text Transfer Protocol version 1.1.
# For details of HTTP, refer to [RFC2616]
# (http://www.ietf.org/rfc/rfc2616.txt).
- #
+ #
# == Examples
- #
+ #
# === Getting Document From WWW Server
- #
+ #
# Example #1: Simple GET+print
- #
+ #
# require 'net/http'
# Net::HTTP.get_print 'www.example.com', '/index.html'
- #
+ #
# Example #2: Simple GET+print by URL
- #
+ #
# require 'net/http'
# require 'uri'
# Net::HTTP.get_print URI.parse('http://www.example.com/index.html')
- #
+ #
# Example #3: More generic GET+print
- #
+ #
# require 'net/http'
# require 'uri'
#
@@ -69,7 +69,7 @@ module Net #:nodoc:
# puts res.body
#
# Example #4: More generic GET+print
- #
+ #
# require 'net/http'
#
# url = URI.parse('http://www.example.com/index.html')
@@ -78,9 +78,9 @@ module Net #:nodoc:
# http.request(req)
# }
# puts res.body
- #
+ #
# === Posting Form Data
- #
+ #
# require 'net/http'
# require 'uri'
#
@@ -112,15 +112,15 @@ module Net #:nodoc:
# res = Net::HTTP.post_form(URI.parse('http://www.example.com/search.cgi'),
# {'q' => ['ruby', 'perl'], 'max' => '50'})
# puts res.body
- #
+ #
# === Accessing via Proxy
- #
+ #
# Net::HTTP.Proxy creates http proxy class. It has same
# methods of Net::HTTP but its instances always connect to
# proxy, instead of given host.
- #
+ #
# require 'net/http'
- #
+ #
# proxy_addr = 'your.proxy.host'
# proxy_port = 8080
# :
@@ -128,20 +128,20 @@ module Net #:nodoc:
# # always connect to your.proxy.addr:8080
# :
# }
- #
+ #
# Since Net::HTTP.Proxy returns Net::HTTP itself when proxy_addr is nil,
# there's no need to change code if there's proxy or not.
- #
+ #
# There are two additional parameters in Net::HTTP.Proxy which allow to
# specify proxy user name and password:
- #
+ #
# Net::HTTP::Proxy(proxy_addr, proxy_port, proxy_user = nil, proxy_pass = nil)
- #
+ #
# You may use them to work with authorization-enabled proxies:
- #
+ #
# require 'net/http'
# require 'uri'
- #
+ #
# proxy_host = 'your.proxy.host'
# proxy_port = 8080
# uri = URI.parse(ENV['http_proxy'])
@@ -154,16 +154,16 @@ module Net #:nodoc:
#
# Note that net/http never rely on HTTP_PROXY environment variable.
# If you want to use proxy, set it explicitly.
- #
+ #
# === Following Redirection
- #
+ #
# require 'net/http'
# require 'uri'
- #
+ #
# def fetch(uri_str, limit = 10)
- # # You should choose better exception.
+ # # You should choose better exception.
# raise ArgumentError, 'HTTP redirect too deep' if limit == 0
- #
+ #
# response = Net::HTTP.get_response(URI.parse(uri_str))
# case response
# when Net::HTTPSuccess then response
@@ -172,25 +172,25 @@ module Net #:nodoc:
# response.error!
# end
# end
- #
+ #
# print fetch('http://www.ruby-lang.org')
- #
+ #
# Net::HTTPSuccess and Net::HTTPRedirection is a HTTPResponse class.
# All HTTPResponse objects belong to its own response class which
# indicate HTTP result status. For details of response classes,
# see section "HTTP Response Classes".
- #
+ #
# === Basic Authentication
- #
+ #
# require 'net/http'
- #
+ #
# Net::HTTP.start('www.example.com') {|http|
# req = Net::HTTP::Get.new('/secret-page.html')
# req.basic_auth 'account', 'password'
# response = http.request(req)
# print response.body
# }
- #
+ #
# === HTTP Request Classes
#
# Here is HTTP request class hierarchy.
@@ -263,22 +263,22 @@ module Net #:nodoc:
# HTTPServiceUnavailable # 503
# HTTPGatewayTimeOut # 504
# HTTPVersionNotSupported # 505
- #
+ #
# == Switching Net::HTTP versions
- #
+ #
# You can use net/http.rb 1.1 features (bundled with Ruby 1.6)
# by calling HTTP.version_1_1. Calling Net::HTTP.version_1_2
# allows you to use 1.2 features again.
- #
+ #
# # example
# Net::HTTP.start {|http1| ...(http1 has 1.2 features)... }
- #
+ #
# Net::HTTP.version_1_1
# Net::HTTP.start {|http2| ...(http2 has 1.1 features)... }
- #
+ #
# Net::HTTP.version_1_2
# Net::HTTP.start {|http3| ...(http3 has 1.2 features)... }
- #
+ #
# This function is NOT thread-safe.
#
class HTTP < Protocol
@@ -338,7 +338,7 @@ module Net #:nodoc:
#
# Get body from target and output it to +$stdout+. The
# target can either be specified as (+uri+), or as
- # (+host+, +path+, +port+ = 80); so:
+ # (+host+, +path+, +port+ = 80); so:
#
# Net::HTTP.get_print URI.parse('http://www.example.com/index.html')
#
@@ -358,7 +358,7 @@ module Net #:nodoc:
# Send a GET request to the target and return the response
# as a string. The target can either be specified as
# (+uri+), or as (+host+, +path+, +port+ = 80); so:
- #
+ #
# print Net::HTTP.get(URI.parse('http://www.example.com/index.html'))
#
# or:
@@ -372,7 +372,7 @@ module Net #:nodoc:
# Send a GET request to the target and return the response
# as a Net::HTTPResponse object. The target can either be specified as
# (+uri+), or as (+host+, +path+, +port+ = 80); so:
- #
+ #
# res = Net::HTTP.get_response(URI.parse('http://www.example.com/index.html'))
# print res.body
#
@@ -442,9 +442,9 @@ module Net #:nodoc:
BufferedIO
end
- # creates a new Net::HTTP object and opens its TCP connection and
- # HTTP session. If the optional block is given, the newly
- # created Net::HTTP object is passed to it and closed when the
+ # creates a new Net::HTTP object and opens its TCP connection and
+ # HTTP session. If the optional block is given, the newly
+ # created Net::HTTP object is passed to it and closed when the
# block finishes. In this case, the return value of this method
# is the return value of the block. If no block is given, the
# return value of this method is the newly created Net::HTTP object
@@ -548,7 +548,7 @@ module Net #:nodoc:
end
# Opens TCP connection and HTTP session.
- #
+ #
# When this method is called with block, gives a HTTP object
# to the block and closes the TCP connection / HTTP session
# after the block executed.
@@ -655,9 +655,9 @@ module Net #:nodoc:
# Arguments are address/port of proxy host and username/password
# if authorization on proxy server is required.
# You can replace the HTTP class with created proxy class.
- #
+ #
# If ADDRESS is nil, this method returns self (Net::HTTP).
- #
+ #
# # Example
# proxy_class = Net::HTTP::Proxy('proxy.example.com', 8080)
# :
@@ -665,7 +665,7 @@ module Net #:nodoc:
# # connecting proxy.foo.org:8080
# :
# }
- #
+ #
def HTTP.Proxy(p_addr, p_port = nil, p_user = nil, p_pass = nil)
return self unless p_addr
delta = ProxyDelta
@@ -765,14 +765,14 @@ module Net #:nodoc:
# and it defaults to an empty hash.
# If +initheader+ doesn't have the key 'accept-encoding', then
# a value of "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" is used,
- # so that gzip compression is used in preference to deflate
- # compression, which is used in preference to no compression.
+ # so that gzip compression is used in preference to deflate
+ # compression, which is used in preference to no compression.
# Ruby doesn't have libraries to support the compress (Lempel-Ziv)
# compression, so that is not supported. The intent of this is
# to reduce bandwidth by default. If this routine sets up
# compression, then it does the decompression also, removing
# the header as well to prevent confusion. Otherwise
- # it leaves the body as it found it.
+ # it leaves the body as it found it.
#
# In version 1.1 (ruby 1.6), this method returns a pair of objects,
# a Net::HTTPResponse object and the entity body string.
@@ -787,7 +787,7 @@ module Net #:nodoc:
# +dest+ argument is obsolete.
# It still works but you must not use it.
#
- # In version 1.1, this method might raise an exception for
+ # In version 1.1, this method might raise an exception for
# 3xx (redirect). In this case you can get a HTTPResponse object
# by "anException.response".
#
@@ -798,7 +798,7 @@ module Net #:nodoc:
#
# # version 1.2 (bundled with Ruby 1.8 or later)
# response = http.get('/index.html')
- #
+ #
# # using block
# File.open('result.txt', 'w') {|f|
# http.get('/~foo/') do |str|
@@ -827,7 +827,7 @@ module Net #:nodoc:
r.delete("content-encoding")
when "identity"
; # nothing needed
- else
+ else
; # Don't do anything dramatic, unless we need to later
end
else
@@ -845,21 +845,21 @@ module Net #:nodoc:
# Gets only the header from +path+ on the connected-to host.
# +header+ is a Hash like { 'Accept' => '*/*', ... }.
- #
+ #
# This method returns a Net::HTTPResponse object.
- #
- # In version 1.1, this method might raise an exception for
+ #
+ # In version 1.1, this method might raise an exception for
# 3xx (redirect). On the case you can get a HTTPResponse object
# by "anException.response".
# In version 1.2, this method never raises an exception.
- #
+ #
# response = nil
# Net::HTTP.start('some.www.server', 80) {|http|
# response = http.head('/index.html')
# }
# p response['content-type']
#
- def head(path, initheader = nil)
+ def head(path, initheader = nil)
res = request(Head.new(path, initheader))
res.value unless @newimpl
res
@@ -867,11 +867,11 @@ module Net #:nodoc:
# Posts +data+ (must be a String) to +path+. +header+ must be a Hash
# like { 'Accept' => '*/*', ... }.
- #
+ #
# In version 1.1 (ruby 1.6), this method returns a pair of objects, a
# Net::HTTPResponse object and an entity body string.
# In version 1.2 (ruby 1.8), this method returns a Net::HTTPResponse object.
- #
+ #
# If called with a block, yields each fragment of the
# entity body in turn as a string as it are read from
# the socket. Note that in this case, the returned response
@@ -879,18 +879,18 @@ module Net #:nodoc:
#
# +dest+ argument is obsolete.
# It still works but you must not use it.
- #
- # In version 1.1, this method might raise an exception for
+ #
+ # In version 1.1, this method might raise an exception for
# 3xx (redirect). In this case you can get an HTTPResponse object
# by "anException.response".
# In version 1.2, this method never raises exception.
- #
+ #
# # version 1.1
# response, body = http.post('/cgi-bin/search.rb', 'query=foo')
- #
+ #
# # version 1.2
# response = http.post('/cgi-bin/search.rb', 'query=foo')
- #
+ #
# # using block
# File.open('result.txt', 'w') {|f|
# http.post('/cgi-bin/search.rb', 'query=foo') do |str|
@@ -983,21 +983,21 @@ module Net #:nodoc:
# Sends a GET request to the +path+ and gets a response,
# as an HTTPResponse object.
- #
+ #
# When called with a block, yields an HTTPResponse object.
# The body of this response will not have been read yet;
# the caller can process it using HTTPResponse#read_body,
# if desired.
#
# Returns the response.
- #
+ #
# This method never raises Net::* exceptions.
- #
+ #
# response = http.request_get('/index.html')
# # The entity body is already read here.
# p response['content-type']
# puts response.body
- #
+ #
# # using block
# http.request_get('/index.html') {|response|
# p response['content-type']
@@ -1014,9 +1014,9 @@ module Net #:nodoc:
# as an HTTPResponse object.
#
# Returns the response.
- #
+ #
# This method never raises Net::* exceptions.
- #
+ #
# response = http.request_head('/index.html')
# p response['content-type']
#
@@ -1026,21 +1026,21 @@ module Net #:nodoc:
# Sends a POST request to the +path+ and gets a response,
# as an HTTPResponse object.
- #
+ #
# When called with a block, yields an HTTPResponse object.
# The body of this response will not have been read yet;
# the caller can process it using HTTPResponse#read_body,
# if desired.
#
# Returns the response.
- #
+ #
# This method never raises Net::* exceptions.
- #
+ #
# # example
# response = http.request_post('/cgi-bin/nice.rb', 'datadatadata...')
# p response.status
# puts response.body # body is already read
- #
+ #
# # using block
# http.request_post('/cgi-bin/nice.rb', 'datadatadata...') {|response|
# p response.status
@@ -1068,7 +1068,7 @@ module Net #:nodoc:
# This method also sends DATA string if DATA is given.
#
# Returns a HTTPResponse object.
- #
+ #
# This method never raises Net::* exceptions.
#
# response = http.send_request('GET', '/index.html')
@@ -1082,14 +1082,14 @@ module Net #:nodoc:
# Sends an HTTPRequest object REQUEST to the HTTP server.
# This method also sends DATA string if REQUEST is a post/put request.
# Giving DATA for get/head request causes ArgumentError.
- #
+ #
# When called with a block, yields an HTTPResponse object.
# The body of this response will not have been read yet;
# the caller can process it using HTTPResponse#read_body,
# if desired.
#
# Returns a HTTPResponse object.
- #
+ #
# This method never raises Net::* exceptions.
#
def request(req, body = nil, &block) # :yield: +response+
@@ -1421,7 +1421,7 @@ module Net #:nodoc:
raise HTTPHeaderSyntaxError, 'wrong Content-Length format'
len.to_i
end
-
+
def content_length=(len)
unless len
@header.delete 'content-length'
@@ -1431,7 +1431,7 @@ module Net #:nodoc:
end
# Returns "true" if the "transfer-encoding" header is present and
- # set to "chunked". This is an HTTP/1.1 feature, allowing the
+ # set to "chunked". This is an HTTP/1.1 feature, allowing the
# the content to be sent in "chunks" without at the outset
# stating the entire content length.
def chunked?
@@ -1472,7 +1472,7 @@ module Net #:nodoc:
return nil unless @header['content-type']
self['Content-Type'].split(';').first.to_s.split('/')[0].to_s.strip
end
-
+
# Returns a content type string such as "html".
# This method returns nil if Content-Type: header field does not exist
# or sub-type is not given (e.g. "Content-Type: text").
@@ -1515,7 +1515,7 @@ module Net #:nodoc:
# http.form_data = {"q" => "ruby", "lang" => "en"}
# http.form_data = {"q" => ["ruby", "perl"], "lang" => "en"}
# http.set_form_data({"q" => "ruby", "lang" => "en"}, ';')
- #
+ #
def set_form_data(params, sep = '&')
self.body = params.map {|k, v| encode_kvpair(k, v) }.flatten.join(sep)
self.content_type = 'application/x-www-form-urlencoded'
@@ -1691,14 +1691,14 @@ module Net #:nodoc:
buf << "\r\n"
sock.write buf
end
-
+
end
- #
+ #
# HTTP request class. This class wraps request header and entity path.
# You *must* use its subclass, Net::HTTP::Get, Post, Head.
- #
+ #
class HTTPRequest < HTTPGenericRequest
# Creates HTTP request object.
@@ -1838,17 +1838,17 @@ module Net #:nodoc:
# HTTP response class. This class wraps response header and entity.
# Mixes in the HTTPHeader module, which provides access to response
# header values both via hash-like methods and individual readers.
- # Note that each possible HTTP response code defines its own
+ # Note that each possible HTTP response code defines its own
# HTTPResponse subclass. These are listed below.
# All classes are
# defined under the Net module. Indentation indicates inheritance.
- #
+ #
# xxx HTTPResponse
- #
+ #
# 1xx HTTPInformation
- # 100 HTTPContinue
+ # 100 HTTPContinue
# 101 HTTPSwitchProtocol
- #
+ #
# 2xx HTTPSuccess
# 200 HTTPOK
# 201 HTTPCreated
@@ -1857,7 +1857,7 @@ module Net #:nodoc:
# 204 HTTPNoContent
# 205 HTTPResetContent
# 206 HTTPPartialContent
- #
+ #
# 3xx HTTPRedirection
# 300 HTTPMultipleChoice
# 301 HTTPMovedPermanently
@@ -1866,7 +1866,7 @@ module Net #:nodoc:
# 304 HTTPNotModified
# 305 HTTPUseProxy
# 307 HTTPTemporaryRedirect
- #
+ #
# 4xx HTTPClientError
# 400 HTTPBadRequest
# 401 HTTPUnauthorized
@@ -1886,7 +1886,7 @@ module Net #:nodoc:
# 415 HTTPUnsupportedMediaType
# 416 HTTPRequestedRangeNotSatisfiable
# 417 HTTPExpectationFailed
- #
+ #
# 5xx HTTPServerError
# 500 HTTPInternalServerError
# 501 HTTPNotImplemented
@@ -1894,7 +1894,7 @@ module Net #:nodoc:
# 503 HTTPServiceUnavailable
# 504 HTTPGatewayTimeOut
# 505 HTTPVersionNotSupported
- #
+ #
# xxx HTTPUnknownResponse
#
class HTTPResponse
@@ -2160,7 +2160,7 @@ module Net #:nodoc:
# next is to fix bug in RDoc, where the private inside class << self
# spills out.
- public
+ public
include HTTPHeader
@@ -2193,7 +2193,7 @@ module Net #:nodoc:
# To allow Net::HTTP 1.1 style assignment
# e.g.
# response, body = Net::HTTP.get(....)
- #
+ #
def to_ary
warn "net/http.rb: warning: Net::HTTP v1.1 style assignment found at #{caller(1)[0]}; use `response = http.get(...)' instead." if $VERBOSE
res = self.dup
diff --git a/lib/net/https.rb b/lib/net/https.rb
index 051e712dc4..636ae1be4d 100644
--- a/lib/net/https.rb
+++ b/lib/net/https.rb
@@ -17,7 +17,7 @@
== Version
$Id$
-
+
2001-11-06: Contiributed to Ruby/OpenSSL project.
2004-03-06: Some code is merged in to net/http.
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 3364561508..161e7ac32a 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -9,7 +9,7 @@
# Documentation: Shugo Maeda, with RDoc conversion and overview by William
# Webber.
#
-# See Net::IMAP for documentation.
+# See Net::IMAP for documentation.
#
@@ -45,12 +45,12 @@ module Net
# read-only access) #examine(). Once the client has successfully
# selected a mailbox, they enter _selected_ state, and that
# mailbox becomes the _current_ mailbox, on which mail-item
- # related commands implicitly operate.
+ # related commands implicitly operate.
#
# Messages have two sorts of identifiers: message sequence
- # numbers, and UIDs.
+ # numbers, and UIDs.
#
- # Message sequence numbers number messages within a mail box
+ # Message sequence numbers number messages within a mail box
# from 1 up to the number of items in the mail box. If new
# message arrives during a session, it receives a sequence
# number equal to the new size of the mail box. If messages
@@ -58,7 +58,7 @@ module Net
# sequence numbers "shuffled down" to fill the gaps.
#
# UIDs, on the other hand, are permanently guaranteed not to
- # identify another message within the same mailbox, even if
+ # identify another message within the same mailbox, even if
# the existing message is deleted. UIDs are required to
# be assigned in ascending (but not necessarily sequential)
# order within a mailbox; this means that if a non-IMAP client
@@ -91,11 +91,11 @@ module Net
# imap.store(message_id, "+FLAGS", [:Deleted])
# end
# imap.expunge
- #
+ #
# == Thread Safety
#
# Net::IMAP supports concurrent threads. For example,
- #
+ #
# imap = Net::IMAP.new("imap.foo.net", "imap2")
# imap.authenticate("cram-md5", "bar", "password")
# imap.select("inbox")
@@ -103,7 +103,7 @@ module Net
# search_result = imap.search(["BODY", "hello"])
# fetch_result = fetch_thread.value
# imap.disconnect
- #
+ #
# This script invokes the FETCH command and the SEARCH command concurrently.
#
# == Errors
@@ -113,9 +113,9 @@ module Net
#
# NO:: the attempted command could not be successfully completed. For
# instance, the username/password used for logging in are incorrect;
- # the selected mailbox does not exists; etc.
+ # the selected mailbox does not exists; etc.
#
- # BAD:: the request from the client does not follow the server's
+ # BAD:: the request from the client does not follow the server's
# understanding of the IMAP protocol. This includes attempting
# commands from the wrong client state; for instance, attempting
# to perform a SEARCH command without having SELECTed a current
@@ -147,8 +147,8 @@ module Net
#
# Finally, a Net::IMAP::DataFormatError is thrown if low-level data
# is found to be in an incorrect format (for instance, when converting
- # between UTF-8 and UTF-16), and Net::IMAP::ResponseParseError is
- # thrown if a server response is non-parseable.
+ # between UTF-8 and UTF-16), and Net::IMAP::ResponseParseError is
+ # thrown if a server response is non-parseable.
#
#
# == References
@@ -274,10 +274,10 @@ module Net
# is the type of authentication this authenticator supports
# (for instance, "LOGIN"). The +authenticator+ is an object
# which defines a process() method to handle authentication with
- # the server. See Net::IMAP::LoginAuthenticator,
+ # the server. See Net::IMAP::LoginAuthenticator,
# Net::IMAP::CramMD5Authenticator, and Net::IMAP::DigestMD5Authenticator
# for examples.
- #
+ #
#
# If +auth_type+ refers to an existing authenticator, it will be
# replaced by the new one.
@@ -314,7 +314,7 @@ module Net
#
# Note that the Net::IMAP class does not modify its
# behaviour according to the capabilities of the server;
- # it is up to the user of the class to ensure that
+ # it is up to the user of the class to ensure that
# a certain capability is supported by a server before
# using it.
def capability
@@ -355,7 +355,7 @@ module Net
# the authentication mechanism to be used. Currently Net::IMAP
# supports authentication mechanisms:
#
- # LOGIN:: login using cleartext user and password.
+ # LOGIN:: login using cleartext user and password.
# CRAM-MD5:: login with cleartext user and encrypted password
# (see [RFC-2195] for a full description). This
# mechanism requires that the server have the user's
@@ -403,7 +403,7 @@ module Net
end
# Sends a SELECT command to select a +mailbox+ so that messages
- # in the +mailbox+ can be accessed.
+ # in the +mailbox+ can be accessed.
#
# After you have selected a mailbox, you may retrieve the
# number of items in that mailbox from @responses["EXISTS"][-1],
@@ -454,7 +454,7 @@ module Net
# Sends a RENAME command to change the name of the +mailbox+ to
# +newname+.
#
- # A Net::IMAP::NoResponseError is raised if a mailbox with the
+ # A Net::IMAP::NoResponseError is raised if a mailbox with the
# name +mailbox+ cannot be renamed to +newname+ for whatever
# reason; for instance, because +mailbox+ does not exist, or
# because there is already a mailbox with the name +newname+.
@@ -501,8 +501,8 @@ module Net
# imap.create("foo/bar")
# imap.create("foo/baz")
# p imap.list("", "foo/%")
- # #=> [#<Net::IMAP::MailboxList attr=[:Noselect], delim="/", name="foo/">, \\
- # #<Net::IMAP::MailboxList attr=[:Noinferiors, :Marked], delim="/", name="foo/bar">, \\
+ # #=> [#<Net::IMAP::MailboxList attr=[:Noselect], delim="/", name="foo/">, \\
+ # #<Net::IMAP::MailboxList attr=[:Noinferiors, :Marked], delim="/", name="foo/bar">, \\
# #<Net::IMAP::MailboxList attr=[:Noinferiors], delim="/", name="foo/baz">]
def list(refname, mailbox)
synchronize do
@@ -555,7 +555,7 @@ module Net
# then that user will be stripped of any rights to that mailbox.
# The IMAP ACL commands are described in [RFC-2086].
def setacl(mailbox, user, rights)
- if rights.nil?
+ if rights.nil?
send_command("SETACL", mailbox, user, "")
else
send_command("SETACL", mailbox, user, rights)
@@ -574,7 +574,7 @@ module Net
# Sends a LSUB command, and returns a subset of names from the set
# of names that the user has declared as being "active" or
- # "subscribed". +refname+ and +mailbox+ are interpreted as
+ # "subscribed". +refname+ and +mailbox+ are interpreted as
# for #list().
# The return value is an array of +Net::IMAP::MailboxList+.
def lsub(refname, mailbox)
@@ -597,7 +597,7 @@ module Net
# p imap.status("inbox", ["MESSAGES", "RECENT"])
# #=> {"RECENT"=>0, "MESSAGES"=>44}
#
- # A Net::IMAP::NoResponseError is raised if status values
+ # A Net::IMAP::NoResponseError is raised if status values
# for +mailbox+ cannot be returned, for instance because it
# does not exist.
def status(mailbox, attr)
@@ -608,9 +608,9 @@ module Net
end
# Sends a APPEND command to append the +message+ to the end of
- # the +mailbox+. The optional +flags+ argument is an array of
+ # the +mailbox+. The optional +flags+ argument is an array of
# flags to initially passing to the new message. The optional
- # +date_time+ argument specifies the creation time to assign to the
+ # +date_time+ argument specifies the creation time to assign to the
# new message; it defaults to the current time.
# For example:
#
@@ -618,7 +618,7 @@ module Net
# Subject: hello
# From: shugo@ruby-lang.org
# To: shugo@ruby-lang.org
- #
+ #
# hello world
# EOF
#
@@ -637,7 +637,7 @@ module Net
# Sends a CHECK command to request a checkpoint of the currently
# selected mailbox. This performs implementation-specific
- # housekeeping, for instance, reconciling the mailbox's
+ # housekeeping, for instance, reconciling the mailbox's
# in-memory and on-disk state.
def check
send_command("CHECK")
@@ -661,8 +661,8 @@ module Net
# Sends a SEARCH command to search the mailbox for messages that
# match the given searching criteria, and returns message sequence
- # numbers. +keys+ can either be a string holding the entire
- # search string, or a single-dimension array of search keywords and
+ # numbers. +keys+ can either be a string holding the entire
+ # search string, or a single-dimension array of search keywords and
# arguments. The following are some common search criteria;
# see [IMAP] section 6.4.4 for a full list.
#
@@ -686,7 +686,7 @@ module Net
#
# OR <search-key> <search-key>:: "or" two search keys together.
#
- # ON <date>:: messages with an internal date exactly equal to <date>,
+ # ON <date>:: messages with an internal date exactly equal to <date>,
# which has a format similar to 8-Aug-2002.
#
# SINCE <date>:: messages with an internal date on or after <date>.
@@ -694,7 +694,7 @@ module Net
# SUBJECT <string>:: messages with <string> in their subject.
#
# TO <string>:: messages with <string> in their TO field.
- #
+ #
# For example:
#
# p imap.search(["SUBJECT", "hello", "NOT", "NEW"])
@@ -717,8 +717,8 @@ module Net
# The return value is an array of Net::IMAP::FetchData. For example:
#
# p imap.fetch(6..8, "UID")
- # #=> [#<Net::IMAP::FetchData seqno=6, attr={"UID"=>98}>, \\
- # #<Net::IMAP::FetchData seqno=7, attr={"UID"=>99}>, \\
+ # #=> [#<Net::IMAP::FetchData seqno=6, attr={"UID"=>98}>, \\
+ # #<Net::IMAP::FetchData seqno=7, attr={"UID"=>99}>, \\
# #<Net::IMAP::FetchData seqno=8, attr={"UID"=>100}>]
# p imap.fetch(6, "BODY[HEADER.FIELDS (SUBJECT)]")
# #=> [#<Net::IMAP::FetchData seqno=6, attr={"BODY[HEADER.FIELDS (SUBJECT)]"=>"Subject: test\r\n\r\n"}>]
@@ -741,9 +741,9 @@ module Net
end
# Sends a STORE command to alter data associated with messages
- # in the mailbox, in particular their flags. The +set+ parameter
- # is a number or an array of numbers or a Range object. Each number
- # is a message sequence number. +attr+ is the name of a data item
+ # in the mailbox, in particular their flags. The +set+ parameter
+ # is a number or an array of numbers or a Range object. Each number
+ # is a message sequence number. +attr+ is the name of a data item
# to store: 'FLAGS' means to replace the message's flag list
# with the provided one; '+FLAGS' means to add the provided flags;
# and '-FLAGS' means to remove them. +flags+ is a list of flags.
@@ -751,8 +751,8 @@ module Net
# The return value is an array of Net::IMAP::FetchData. For example:
#
# p imap.store(6..8, "+FLAGS", [:Deleted])
- # #=> [#<Net::IMAP::FetchData seqno=6, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
- # #<Net::IMAP::FetchData seqno=7, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
+ # #=> [#<Net::IMAP::FetchData seqno=6, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
+ # #<Net::IMAP::FetchData seqno=7, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
# #<Net::IMAP::FetchData seqno=8, attr={"FLAGS"=>[:Seen, :Deleted]}>]
def store(set, attr, flags)
return store_internal("STORE", set, attr, flags)
@@ -794,9 +794,9 @@ module Net
return sort_internal("UID SORT", sort_keys, search_keys, charset)
end
- # Adds a response handler. For example, to detect when
+ # Adds a response handler. For example, to detect when
# the server sends us a new EXISTS response (which normally
- # indicates new messages being added to the mail box),
+ # indicates new messages being added to the mail box),
# you could add the following handler after selecting the
# mailbox.
#
@@ -832,7 +832,7 @@ module Net
return thread_internal("THREAD", algorithm, search_keys, charset)
end
- # As for #thread(), but returns unique identifiers instead of
+ # As for #thread(), but returns unique identifiers instead of
# message sequence numbers.
def uid_thread(algorithm, search_keys, charset)
return thread_internal("UID THREAD", algorithm, search_keys, charset)
@@ -897,7 +897,7 @@ module Net
# to use SSL (now TLS) to connect to the server. For this to work
# OpenSSL [OSSL] and the Ruby OpenSSL [RSSL] extensions need to
# be installed.
- # if options[:ssl] is a hash, it's passed to
+ # if options[:ssl] is a hash, it's passed to
# OpenSSL::SSL::SSLContext#set_params as parameters.
#
# The most common errors are:
@@ -908,7 +908,7 @@ module Net
# being dropped by an intervening firewall).
# Errno::ENETUNREACH:: there is no route to that network.
# SocketError:: hostname not known or other socket error.
- # Net::IMAP::ByeResponseError:: we connected to the host, but they
+ # Net::IMAP::ByeResponseError:: we connected to the host, but they
# immediately said goodbye to us.
def initialize(host, port_or_options = {},
usessl = false, certs = nil, verify = true)
@@ -1092,7 +1092,7 @@ module Net
@tagno += 1
return format("%s%04d", @tag_prefix, @tagno)
end
-
+
def put_string(str)
@sock.print(str)
if @@debug
@@ -1160,7 +1160,7 @@ module Net
put_string(str)
end
end
-
+
def send_quoted_string(str)
put_string('"' + str.gsub(/["\\]/n, "\\\\\\&") + '"')
end
@@ -1313,7 +1313,7 @@ module Net
context = SSLContext.new
context.set_params(params)
if defined?(VerifyCallbackProc)
- context.verify_callback = VerifyCallbackProc
+ context.verify_callback = VerifyCallbackProc
end
@sock = SSLSocket.new(@sock, context)
@sock.sync_close = true
@@ -1448,109 +1448,109 @@ module Net
end
# Net::IMAP::ContinuationRequest represents command continuation requests.
- #
+ #
# The command continuation request response is indicated by a "+" token
# instead of a tag. This form of response indicates that the server is
# ready to accept the continuation of a command from the client. The
# remainder of this response is a line of text.
- #
+ #
# continue_req ::= "+" SPACE (resp_text / base64)
- #
+ #
# ==== Fields:
- #
+ #
# data:: Returns the data (Net::IMAP::ResponseText).
- #
+ #
# raw_data:: Returns the raw data string.
ContinuationRequest = Struct.new(:data, :raw_data)
# Net::IMAP::UntaggedResponse represents untagged responses.
- #
+ #
# Data transmitted by the server to the client and status responses
# that do not indicate command completion are prefixed with the token
# "*", and are called untagged responses.
- #
+ #
# response_data ::= "*" SPACE (resp_cond_state / resp_cond_bye /
# mailbox_data / message_data / capability_data)
- #
+ #
# ==== Fields:
- #
+ #
# name:: Returns the name such as "FLAGS", "LIST", "FETCH"....
- #
+ #
# data:: Returns the data such as an array of flag symbols,
# a ((<Net::IMAP::MailboxList>)) object....
- #
+ #
# raw_data:: Returns the raw data string.
UntaggedResponse = Struct.new(:name, :data, :raw_data)
-
+
# Net::IMAP::TaggedResponse represents tagged responses.
- #
+ #
# The server completion result response indicates the success or
# failure of the operation. It is tagged with the same tag as the
# client command which began the operation.
- #
+ #
# response_tagged ::= tag SPACE resp_cond_state CRLF
- #
+ #
# tag ::= 1*<any ATOM_CHAR except "+">
- #
+ #
# resp_cond_state ::= ("OK" / "NO" / "BAD") SPACE resp_text
- #
+ #
# ==== Fields:
- #
+ #
# tag:: Returns the tag.
- #
+ #
# name:: Returns the name. the name is one of "OK", "NO", "BAD".
- #
+ #
# data:: Returns the data. See ((<Net::IMAP::ResponseText>)).
- #
+ #
# raw_data:: Returns the raw data string.
#
TaggedResponse = Struct.new(:tag, :name, :data, :raw_data)
-
+
# Net::IMAP::ResponseText represents texts of responses.
# The text may be prefixed by the response code.
- #
+ #
# resp_text ::= ["[" resp_text_code "]" SPACE] (text_mime2 / text)
# ;; text SHOULD NOT begin with "[" or "="
- #
+ #
# ==== Fields:
- #
+ #
# code:: Returns the response code. See ((<Net::IMAP::ResponseCode>)).
- #
+ #
# text:: Returns the text.
- #
+ #
ResponseText = Struct.new(:code, :text)
- #
+ #
# Net::IMAP::ResponseCode represents response codes.
- #
+ #
# resp_text_code ::= "ALERT" / "PARSE" /
# "PERMANENTFLAGS" SPACE "(" #(flag / "\*") ")" /
# "READ-ONLY" / "READ-WRITE" / "TRYCREATE" /
# "UIDVALIDITY" SPACE nz_number /
# "UNSEEN" SPACE nz_number /
# atom [SPACE 1*<any TEXT_CHAR except "]">]
- #
+ #
# ==== Fields:
- #
+ #
# name:: Returns the name such as "ALERT", "PERMANENTFLAGS", "UIDVALIDITY"....
- #
+ #
# data:: Returns the data if it exists.
#
ResponseCode = Struct.new(:name, :data)
# Net::IMAP::MailboxList represents contents of the LIST response.
- #
+ #
# mailbox_list ::= "(" #("\Marked" / "\Noinferiors" /
# "\Noselect" / "\Unmarked" / flag_extension) ")"
# SPACE (<"> QUOTED_CHAR <"> / nil) SPACE mailbox
- #
+ #
# ==== Fields:
- #
+ #
# attr:: Returns the name attributes. Each name attribute is a symbol
# capitalized by String#capitalize, such as :Noselect (not :NoSelect).
- #
+ #
# delim:: Returns the hierarchy delimiter
- #
+ #
# name:: Returns the mailbox name.
#
MailboxList = Struct.new(:attr, :delim, :name)
@@ -1559,78 +1559,78 @@ module Net
# This object can also be a response to GETQUOTAROOT. In the syntax
# specification below, the delimiter used with the "#" construct is a
# single space (SPACE).
- #
+ #
# quota_list ::= "(" #quota_resource ")"
- #
+ #
# quota_resource ::= atom SPACE number SPACE number
- #
+ #
# quota_response ::= "QUOTA" SPACE astring SPACE quota_list
- #
+ #
# ==== Fields:
- #
+ #
# mailbox:: The mailbox with the associated quota.
- #
+ #
# usage:: Current storage usage of mailbox.
- #
+ #
# quota:: Quota limit imposed on mailbox.
#
MailboxQuota = Struct.new(:mailbox, :usage, :quota)
# Net::IMAP::MailboxQuotaRoot represents part of the GETQUOTAROOT
# response. (GETQUOTAROOT can also return Net::IMAP::MailboxQuota.)
- #
+ #
# quotaroot_response ::= "QUOTAROOT" SPACE astring *(SPACE astring)
- #
+ #
# ==== Fields:
- #
+ #
# mailbox:: The mailbox with the associated quota.
- #
+ #
# quotaroots:: Zero or more quotaroots that effect the quota on the
# specified mailbox.
#
MailboxQuotaRoot = Struct.new(:mailbox, :quotaroots)
# Net::IMAP::MailboxACLItem represents response from GETACL.
- #
+ #
# acl_data ::= "ACL" SPACE mailbox *(SPACE identifier SPACE rights)
- #
+ #
# identifier ::= astring
- #
+ #
# rights ::= astring
- #
+ #
# ==== Fields:
- #
+ #
# user:: Login name that has certain rights to the mailbox
# that was specified with the getacl command.
- #
+ #
# rights:: The access rights the indicated user has to the
# mailbox.
#
MailboxACLItem = Struct.new(:user, :rights)
# Net::IMAP::StatusData represents contents of the STATUS response.
- #
+ #
# ==== Fields:
- #
+ #
# mailbox:: Returns the mailbox name.
- #
+ #
# attr:: Returns a hash. Each key is one of "MESSAGES", "RECENT", "UIDNEXT",
# "UIDVALIDITY", "UNSEEN". Each value is a number.
- #
+ #
StatusData = Struct.new(:mailbox, :attr)
# Net::IMAP::FetchData represents contents of the FETCH response.
- #
+ #
# ==== Fields:
- #
+ #
# seqno:: Returns the message sequence number.
# (Note: not the unique identifier, even for the UID command response.)
- #
+ #
# attr:: Returns a hash. Each key is a data item name, and each value is
# its value.
- #
+ #
# The current data items are:
- #
+ #
# [BODY]
# A form of BODYSTRUCTURE without extension data.
# [BODY[<section>]<<origin_octet>>]
@@ -1657,67 +1657,67 @@ module Net
# Equivalent to BODY[TEXT].
# [UID]
# A number expressing the unique identifier of the message.
- #
+ #
FetchData = Struct.new(:seqno, :attr)
# Net::IMAP::Envelope represents envelope structures of messages.
- #
+ #
# ==== Fields:
- #
+ #
# date:: Returns a string that represents the date.
- #
+ #
# subject:: Returns a string that represents the subject.
- #
+ #
# from:: Returns an array of Net::IMAP::Address that represents the from.
- #
+ #
# sender:: Returns an array of Net::IMAP::Address that represents the sender.
- #
+ #
# reply_to:: Returns an array of Net::IMAP::Address that represents the reply-to.
- #
+ #
# to:: Returns an array of Net::IMAP::Address that represents the to.
- #
+ #
# cc:: Returns an array of Net::IMAP::Address that represents the cc.
- #
+ #
# bcc:: Returns an array of Net::IMAP::Address that represents the bcc.
- #
+ #
# in_reply_to:: Returns a string that represents the in-reply-to.
- #
+ #
# message_id:: Returns a string that represents the message-id.
- #
+ #
Envelope = Struct.new(:date, :subject, :from, :sender, :reply_to,
:to, :cc, :bcc, :in_reply_to, :message_id)
- #
+ #
# Net::IMAP::Address represents electronic mail addresses.
- #
+ #
# ==== Fields:
- #
+ #
# name:: Returns the phrase from [RFC-822] mailbox.
- #
+ #
# route:: Returns the route from [RFC-822] route-addr.
- #
+ #
# mailbox:: nil indicates end of [RFC-822] group.
# If non-nil and host is nil, returns [RFC-822] group name.
# Otherwise, returns [RFC-822] local-part
- #
+ #
# host:: nil indicates [RFC-822] group syntax.
# Otherwise, returns [RFC-822] domain name.
#
Address = Struct.new(:name, :route, :mailbox, :host)
- #
+ #
# Net::IMAP::ContentDisposition represents Content-Disposition fields.
- #
+ #
# ==== Fields:
- #
+ #
# dsp_type:: Returns the disposition type.
- #
+ #
# param:: Returns a hash that represents parameters of the Content-Disposition
# field.
- #
+ #
ContentDisposition = Struct.new(:dsp_type, :param)
- # Net::IMAP::ThreadMember represents a thread-node returned
+ # Net::IMAP::ThreadMember represents a thread-node returned
# by Net::IMAP#thread
#
# ==== Fields:
@@ -1730,37 +1730,37 @@ module Net
ThreadMember = Struct.new(:seqno, :children)
# Net::IMAP::BodyTypeBasic represents basic body structures of messages.
- #
+ #
# ==== Fields:
- #
+ #
# media_type:: Returns the content media type name as defined in [MIME-IMB].
- #
+ #
# subtype:: Returns the content subtype name as defined in [MIME-IMB].
- #
+ #
# param:: Returns a hash that represents parameters as defined in [MIME-IMB].
- #
+ #
# content_id:: Returns a string giving the content id as defined in [MIME-IMB].
- #
+ #
# description:: Returns a string giving the content description as defined in
# [MIME-IMB].
- #
+ #
# encoding:: Returns a string giving the content transfer encoding as defined in
# [MIME-IMB].
- #
+ #
# size:: Returns a number giving the size of the body in octets.
- #
+ #
# md5:: Returns a string giving the body MD5 value as defined in [MD5].
- #
+ #
# disposition:: Returns a Net::IMAP::ContentDisposition object giving
# the content disposition.
- #
+ #
# language:: Returns a string or an array of strings giving the body
# language value as defined in [LANGUAGE-TAGS].
- #
+ #
# extension:: Returns extension data.
- #
+ #
# multipart?:: Returns false.
- #
+ #
class BodyTypeBasic < Struct.new(:media_type, :subtype,
:param, :content_id,
:description, :encoding, :size,
@@ -1771,7 +1771,7 @@ module Net
end
# Obsolete: use +subtype+ instead. Calling this will
- # generate a warning message to +stderr+, then return
+ # generate a warning message to +stderr+, then return
# the value of +subtype+.
def media_subtype
$stderr.printf("warning: media_subtype is obsolete.\n")
@@ -1781,13 +1781,13 @@ module Net
end
# Net::IMAP::BodyTypeText represents TEXT body structures of messages.
- #
+ #
# ==== Fields:
- #
+ #
# lines:: Returns the size of the body in text lines.
- #
+ #
# And Net::IMAP::BodyTypeText has all fields of Net::IMAP::BodyTypeBasic.
- #
+ #
class BodyTypeText < Struct.new(:media_type, :subtype,
:param, :content_id,
:description, :encoding, :size,
@@ -1799,7 +1799,7 @@ module Net
end
# Obsolete: use +subtype+ instead. Calling this will
- # generate a warning message to +stderr+, then return
+ # generate a warning message to +stderr+, then return
# the value of +subtype+.
def media_subtype
$stderr.printf("warning: media_subtype is obsolete.\n")
@@ -1809,13 +1809,13 @@ module Net
end
# Net::IMAP::BodyTypeMessage represents MESSAGE/RFC822 body structures of messages.
- #
+ #
# ==== Fields:
- #
+ #
# envelope:: Returns a Net::IMAP::Envelope giving the envelope structure.
- #
+ #
# body:: Returns an object giving the body structure.
- #
+ #
# And Net::IMAP::BodyTypeMessage has all methods of Net::IMAP::BodyTypeText.
#
class BodyTypeMessage < Struct.new(:media_type, :subtype,
@@ -1829,7 +1829,7 @@ module Net
end
# Obsolete: use +subtype+ instead. Calling this will
- # generate a warning message to +stderr+, then return
+ # generate a warning message to +stderr+, then return
# the value of +subtype+.
def media_subtype
$stderr.printf("warning: media_subtype is obsolete.\n")
@@ -1838,29 +1838,29 @@ module Net
end
end
- # Net::IMAP::BodyTypeMultipart represents multipart body structures
+ # Net::IMAP::BodyTypeMultipart represents multipart body structures
# of messages.
- #
+ #
# ==== Fields:
- #
+ #
# media_type:: Returns the content media type name as defined in [MIME-IMB].
- #
+ #
# subtype:: Returns the content subtype name as defined in [MIME-IMB].
- #
+ #
# parts:: Returns multiple parts.
- #
+ #
# param:: Returns a hash that represents parameters as defined in [MIME-IMB].
- #
+ #
# disposition:: Returns a Net::IMAP::ContentDisposition object giving
# the content disposition.
- #
+ #
# language:: Returns a string or an array of strings giving the body
# language value as defined in [LANGUAGE-TAGS].
- #
+ #
# extension:: Returns extension data.
- #
+ #
# multipart?:: Returns true.
- #
+ #
class BodyTypeMultipart < Struct.new(:media_type, :subtype,
:parts,
:param, :disposition, :language,
@@ -1870,7 +1870,7 @@ module Net
end
# Obsolete: use +subtype+ instead. Calling this will
- # generate a warning message to +stderr+, then return
+ # generate a warning message to +stderr+, then return
# the value of +subtype+.
def media_subtype
$stderr.printf("warning: media_subtype is obsolete.\n")
@@ -2671,35 +2671,35 @@ module Net
def thread_branch(token)
rootmember = nil
lastmember = nil
-
+
while true
shift_token # ignore first T_LPAR
token = lookahead
-
+
case token.symbol
when T_NUMBER
# new member
newmember = ThreadMember.new(number, [])
if rootmember.nil?
rootmember = newmember
- else
+ else
lastmember.children << newmember
- end
+ end
lastmember = newmember
- when T_SPACE
- # do nothing
+ when T_SPACE
+ # do nothing
when T_LPAR
if rootmember.nil?
# dummy member
lastmember = rootmember = ThreadMember.new(nil, [])
- end
-
+ end
+
lastmember.children << thread_branch(token)
when T_RPAR
- break
- end
+ break
+ end
end
-
+
return rootmember
end
@@ -3176,7 +3176,7 @@ module Net
@user = user
@password = password
end
- end
+ end
add_authenticator "PLAIN", PlainAuthenticator
# Authenticator for the "CRAM-MD5" authentication type. See
@@ -3341,7 +3341,7 @@ module Net
class BadResponseError < ResponseError
end
- # Error raised upon a "BYE" response from the server, indicating
+ # Error raised upon a "BYE" response from the server, indicating
# that the client is not being allowed to login, or has been timed
# out due to inactivity.
class ByeResponseError < ResponseError
@@ -3426,7 +3426,7 @@ EOF
usage
exit(1)
end
-
+
imap = Net::IMAP.new($host, :port => $port, :ssl => $ssl)
begin
password = get_password
diff --git a/lib/net/pop.rb b/lib/net/pop.rb
index accac72905..6a45e3b5f0 100644
--- a/lib/net/pop.rb
+++ b/lib/net/pop.rb
@@ -3,20 +3,20 @@
# Copyright (c) 1999-2007 Yukihiro Matsumoto.
#
# Copyright (c) 1999-2007 Minero Aoki.
-#
+#
# Written & maintained by Minero Aoki <aamine@loveruby.net>.
#
# Documented by William Webber and Minero Aoki.
-#
+#
# This program is free software. You can re-distribute and/or
# modify this program under the same terms as Ruby itself,
# Ruby Distribute License.
-#
+#
# NOTE: You can find Japanese version of this document at:
# http://www.ruby-lang.org/ja/man/html/net_pop.html
-#
+#
# $Id$
-#
+#
# See Net::POP3 for documentation.
#
@@ -45,25 +45,25 @@ module Net
# = Net::POP3
#
# == What is This Library?
- #
- # This library provides functionality for retrieving
+ #
+ # This library provides functionality for retrieving
# email via POP3, the Post Office Protocol version 3. For details
# of POP3, see [RFC1939] (http://www.ietf.org/rfc/rfc1939.txt).
- #
+ #
# == Examples
- #
- # === Retrieving Messages
- #
- # This example retrieves messages from the server and deletes them
+ #
+ # === Retrieving Messages
+ #
+ # This example retrieves messages from the server and deletes them
# on the server.
#
# Messages are written to files named 'inbox/1', 'inbox/2', ....
# Replace 'pop.example.com' with your POP3 server address, and
# 'YourAccount' and 'YourPassword' with the appropriate account
# details.
- #
+ #
# require 'net/pop'
- #
+ #
# pop = Net::POP3.new('pop.example.com')
# pop.start('YourAccount', 'YourPassword') # (1)
# if pop.mails.empty?
@@ -80,19 +80,19 @@ module Net
# puts "#{pop.mails.size} mails popped."
# end
# pop.finish # (3)
- #
+ #
# 1. Call Net::POP3#start and start POP session.
# 2. Access messages by using POP3#each_mail and/or POP3#mails.
# 3. Close POP session by calling POP3#finish or use the block form of #start.
- #
+ #
# === Shortened Code
- #
+ #
# The example above is very verbose. You can shorten the code by using
# some utility methods. First, the block form of Net::POP3.start can
# be used instead of POP3.new, POP3#start and POP3#finish.
- #
+ #
# require 'net/pop'
- #
+ #
# Net::POP3.start('pop.example.com', 110,
# 'YourAccount', 'YourPassword') do |pop|
# if pop.mails.empty?
@@ -109,11 +109,11 @@ module Net
# puts "#{pop.mails.size} mails popped."
# end
# end
- #
+ #
# POP3#delete_all is an alternative for #each_mail and #delete.
- #
+ #
# require 'net/pop'
- #
+ #
# Net::POP3.start('pop.example.com', 110,
# 'YourAccount', 'YourPassword') do |pop|
# if pop.mails.empty?
@@ -128,11 +128,11 @@ module Net
# end
# end
# end
- #
+ #
# And here is an even shorter example.
- #
+ #
# require 'net/pop'
- #
+ #
# i = 0
# Net::POP3.delete_all('pop.example.com', 110,
# 'YourAccount', 'YourPassword') do |m|
@@ -141,14 +141,14 @@ module Net
# end
# i += 1
# end
- #
+ #
# === Memory Space Issues
- #
+ #
# All the examples above get each message as one big string.
# This example avoids this.
- #
+ #
# require 'net/pop'
- #
+ #
# i = 1
# Net::POP3.delete_all('pop.example.com', 110,
# 'YourAccount', 'YourPassword') do |m|
@@ -159,41 +159,41 @@ module Net
# i += 1
# end
# end
- #
+ #
# === Using APOP
- #
+ #
# The net/pop library supports APOP authentication.
# To use APOP, use the Net::APOP class instead of the Net::POP3 class.
# You can use the utility method, Net::POP3.APOP(). For example:
- #
+ #
# require 'net/pop'
- #
+ #
# # Use APOP authentication if $isapop == true
# pop = Net::POP3.APOP($is_apop).new('apop.example.com', 110)
# pop.start(YourAccount', 'YourPassword') do |pop|
# # Rest of the code is the same.
# end
- #
+ #
# === Fetch Only Selected Mail Using 'UIDL' POP Command
- #
+ #
# If your POP server provides UIDL functionality,
# you can grab only selected mails from the POP server.
# e.g.
- #
+ #
# def need_pop?( id )
# # determine if we need pop this mail...
# end
- #
+ #
# Net::POP3.start('pop.example.com', 110,
# 'Your account', 'Your password') do |pop|
# pop.mails.select { |m| need_pop?(m.unique_id) }.each do |m|
# do_something(m.pop)
# end
# end
- #
+ #
# The POPMail#unique_id() method returns the unique-id of the message as a
# String. Normally the unique-id is a hash of the message.
- #
+ #
class POP3 < Protocol
Revision = %q$Revision$.split[1]
@@ -210,7 +210,7 @@ module Net
def POP3.default_pop3_port
110
end
-
+
# The default port for POP3S connections, port 995
def POP3.default_pop3s_port
995
@@ -375,7 +375,7 @@ module Net
# Session management
#
- # Creates a new POP3 object and open the connection. Equivalent to
+ # Creates a new POP3 object and open the connection. Equivalent to
#
# Net::POP3.new(address, port, isapop).start(account, password)
#
@@ -396,7 +396,7 @@ module Net
isapop = false, &block) # :yield: pop
new(address, port, isapop).start(account, password, &block)
end
-
+
# Creates a new POP3 object.
#
# +address+ is the hostname or ip address of your POP3 server.
@@ -412,7 +412,7 @@ module Net
@ssl_params = POP3.ssl_params
@port = port
@apop = isapop
-
+
@command = nil
@socket = nil
@started = false
@@ -434,7 +434,7 @@ module Net
def use_ssl?
return !@ssl_params.nil?
end
-
+
# call-seq:
# Net::POP#enable_ssl(params = {})
#
@@ -451,7 +451,7 @@ module Net
@port = port || @port
end
end
-
+
def disable_ssl
@ssl_params = nil
end
@@ -635,7 +635,7 @@ module Net
# Yields each message to the passed-in block in turn.
# Equivalent to:
- #
+ #
# pop3.mails.each do |popmail|
# ....
# end
@@ -742,7 +742,7 @@ module Net
#
# This method fetches the message. If called with a block, the
# message is yielded to the block one chunk at a time. If called
- # without a block, the message is returned as a String. The optional
+ # without a block, the message is returned as a String. The optional
# +dest+ argument will be prepended to the returned String; this
# argument is essentially obsolete.
#
@@ -753,7 +753,7 @@ module Net
# n = 1
# pop.mails.each do |popmail|
# File.open("inbox/#{n}", 'w') do |f|
- # f.write popmail.pop
+ # f.write popmail.pop
# end
# popmail.delete
# n += 1
@@ -792,7 +792,7 @@ module Net
alias all pop #:nodoc: obsolete
alias mail pop #:nodoc: obsolete
- # Fetches the message header and +lines+ lines of body.
+ # Fetches the message header and +lines+ lines of body.
#
# The optional +dest+ argument is obsolete.
#
@@ -804,7 +804,7 @@ module Net
dest
end
- # Fetches the message header.
+ # Fetches the message header.
#
# The optional +dest+ argument is obsolete.
#
@@ -933,7 +933,7 @@ module Net
@socket.each_message_chunk(&block)
}
end
-
+
def dele(num)
check_response(critical { get_response('DELE %d', num) })
end
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index e26c849338..e2423f2986 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -121,7 +121,7 @@ module Net # :nodoc:
return rbuf_consume(@rbuf.size)
end
end
-
+
def readline
readuntil("\n").chop
end
@@ -228,7 +228,7 @@ module Net # :nodoc:
LOG_on()
LOG "read message (#{read_bytes} bytes)"
end
-
+
# *library private* (cannot handle 'break')
def each_list_item
while (str = readuntil("\r\n")) != ".\r\n"
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index b58e73029b..a84b7ba154 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -1,23 +1,23 @@
# = net/smtp.rb
-#
+#
# Copyright (c) 1999-2007 Yukihiro Matsumoto.
#
# Copyright (c) 1999-2007 Minero Aoki.
-#
+#
# Written & maintained by Minero Aoki <aamine@loveruby.net>.
#
# Documented by William Webber and Minero Aoki.
-#
+#
# This program is free software. You can re-distribute and/or
# modify this program under the same terms as Ruby itself.
-#
+#
# NOTE: You can find Japanese version of this document at:
# http://www.ruby-lang.org/ja/man/html/net_smtp.html
-#
+#
# $Id$
#
-# See Net::SMTP for documentation.
-#
+# See Net::SMTP for documentation.
+#
require 'net/protocol'
require 'digest/md5'
@@ -69,103 +69,103 @@ module Net
# = Net::SMTP
#
# == What is This Library?
- #
+ #
# This library provides functionality to send internet
# mail via SMTP, the Simple Mail Transfer Protocol. For details of
# SMTP itself, see [RFC2821] (http://www.ietf.org/rfc/rfc2821.txt).
- #
+ #
# == What is This Library NOT?
- #
+ #
# This library does NOT provide functions to compose internet mails.
# You must create them by yourself. If you want better mail support,
# try RubyMail or TMail. You can get both libraries from RAA.
# (http://www.ruby-lang.org/en/raa.html)
- #
+ #
# FYI: the official documentation on internet mail is: [RFC2822] (http://www.ietf.org/rfc/rfc2822.txt).
- #
+ #
# == Examples
- #
+ #
# === Sending Messages
- #
+ #
# You must open a connection to an SMTP server before sending messages.
- # The first argument is the address of your SMTP server, and the second
- # argument is the port number. Using SMTP.start with a block is the simplest
- # way to do this. This way, the SMTP connection is closed automatically
+ # The first argument is the address of your SMTP server, and the second
+ # argument is the port number. Using SMTP.start with a block is the simplest
+ # way to do this. This way, the SMTP connection is closed automatically
# after the block is executed.
- #
+ #
# require 'net/smtp'
# Net::SMTP.start('your.smtp.server', 25) do |smtp|
# # Use the SMTP object smtp only in this block.
# end
- #
+ #
# Replace 'your.smtp.server' with your SMTP server. Normally
# your system manager or internet provider supplies a server
# for you.
- #
+ #
# Then you can send messages.
- #
+ #
# msgstr = <<END_OF_MESSAGE
# From: Your Name <your@mail.address>
# To: Destination Address <someone@example.com>
# Subject: test message
# Date: Sat, 23 Jun 2001 16:26:43 +0900
# Message-Id: <unique.message.id.string@example.com>
- #
+ #
# This is a test message.
# END_OF_MESSAGE
- #
+ #
# require 'net/smtp'
# Net::SMTP.start('your.smtp.server', 25) do |smtp|
# smtp.send_message msgstr,
# 'your@mail.address',
# 'his_addess@example.com'
# end
- #
+ #
# === Closing the Session
- #
- # You MUST close the SMTP session after sending messages, by calling
+ #
+ # You MUST close the SMTP session after sending messages, by calling
# the #finish method:
- #
+ #
# # using SMTP#finish
# smtp = Net::SMTP.start('your.smtp.server', 25)
# smtp.send_message msgstr, 'from@address', 'to@address'
# smtp.finish
- #
+ #
# You can also use the block form of SMTP.start/SMTP#start. This closes
# the SMTP session automatically:
- #
+ #
# # using block form of SMTP.start
# Net::SMTP.start('your.smtp.server', 25) do |smtp|
# smtp.send_message msgstr, 'from@address', 'to@address'
# end
- #
+ #
# I strongly recommend this scheme. This form is simpler and more robust.
- #
+ #
# === HELO domain
- #
+ #
# In almost all situations, you must provide a third argument
# to SMTP.start/SMTP#start. This is the domain name which you are on
# (the host to send mail from). It is called the "HELO domain".
# The SMTP server will judge whether it should send or reject
# the SMTP session by inspecting the HELO domain.
- #
+ #
# Net::SMTP.start('your.smtp.server', 25,
# 'mail.from.domain') { |smtp| ... }
- #
+ #
# === SMTP Authentication
- #
+ #
# The Net::SMTP class supports three authentication schemes;
# PLAIN, LOGIN and CRAM MD5. (SMTP Authentication: [RFC2554])
- # To use SMTP authentication, pass extra arguments to
+ # To use SMTP authentication, pass extra arguments to
# SMTP.start/SMTP#start.
- #
+ #
# # PLAIN
# Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
# 'Your Account', 'Your Password', :plain)
# # LOGIN
# Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
# 'Your Account', 'Your Password', :login)
- #
+ #
# # CRAM MD5
# Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
# 'Your Account', 'Your Password', :cram_md5)
@@ -196,7 +196,7 @@ module Net
def SMTP.default_ssl_context
OpenSSL::SSL::SSLContext.new
end
-
+
#
# Creates a new Net::SMTP object.
#
@@ -223,7 +223,7 @@ module Net
@starttls = false
@ssl_context = nil
end
-
+
# Provide human-readable stringification of class state.
def inspect
"#<#{self.class} #{@address}:#{@port} started=#{@started}>"
@@ -235,7 +235,7 @@ module Net
end
#
- # Set whether to use ESMTP or not. This should be done before
+ # Set whether to use ESMTP or not. This should be done before
# calling #start. Note that if #start is called in ESMTP mode,
# and the connection fails due to a ProtocolError, the SMTP
# object will automatically switch to plain SMTP mode and
@@ -310,7 +310,7 @@ module Net
end
alias enable_ssl enable_tls
-
+
# Disables SMTP/TLS for this object. Must be called before the
# connection is established to have any effect.
def disable_tls
@@ -336,7 +336,7 @@ module Net
def starttls_auto?
@starttls == :auto
end
-
+
# Enables SMTP/TLS (STARTTLS) for this object.
# +context+ is a OpenSSL::SSL::SSLContext object.
def enable_starttls(context = SMTP.default_ssl_context)
@@ -413,7 +413,7 @@ module Net
# Creates a new Net::SMTP object and connects to the server.
#
# This method is equivalent to:
- #
+ #
# Net::SMTP.new(address, port).start(helo_domain, account, password, authtype)
#
# === Example
@@ -437,7 +437,7 @@ module Net
# +port+ is the port to connect to; it defaults to port 25.
#
# +helo+ is the _HELO_ _domain_ provided by the client to the
- # server (see overview comments); it defaults to 'localhost'.
+ # server (see overview comments); it defaults to 'localhost'.
#
# The remaining arguments are used for SMTP authentication, if required
# or desired. +user+ is the account name; +secret+ is your password
@@ -476,33 +476,33 @@ module Net
# +helo+ is the _HELO_ _domain_ that you'll dispatch mails from; see
# the discussion in the overview notes.
#
- # If both of +user+ and +secret+ are given, SMTP authentication
- # will be attempted using the AUTH command. +authtype+ specifies
+ # If both of +user+ and +secret+ are given, SMTP authentication
+ # will be attempted using the AUTH command. +authtype+ specifies
# the type of authentication to attempt; it must be one of
# :login, :plain, and :cram_md5. See the notes on SMTP Authentication
- # in the overview.
+ # in the overview.
#
# === Block Usage
#
# When this methods is called with a block, the newly-started SMTP
# object is yielded to the block, and automatically closed after
- # the block call finishes. Otherwise, it is the caller's
+ # the block call finishes. Otherwise, it is the caller's
# responsibility to close the session when finished.
#
# === Example
#
# This is very similar to the class method SMTP.start.
#
- # require 'net/smtp'
+ # require 'net/smtp'
# smtp = Net::SMTP.new('smtp.mail.server', 25)
# smtp.start(helo_domain, account, password, authtype) do |smtp|
# smtp.send_message msgstr, 'from@example.com', ['dest@example.com']
- # end
+ # end
#
# The primary use of this method (as opposed to SMTP.start)
# is probably to set debugging (#set_debug_output) or ESMTP
# (#esmtp=), which must be done before the session is
- # started.
+ # started.
#
# === Errors
#
@@ -548,7 +548,7 @@ module Net
check_auth_method(authtype || DEFAULT_AUTH_TYPE)
check_auth_args user, secret
end
- s = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
+ s = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
logging "Connection opened: #{@address}:#{@port}"
@socket = new_internet_message_io(tls? ? tlsconnect(s) : s)
check_response critical { recv_response() }
@@ -621,7 +621,7 @@ module Net
#
# Sends +msgstr+ as a message. Single CR ("\r") and LF ("\n") found
# in the +msgstr+, are converted into the CR LF pair. You cannot send a
- # binary message with this method. +msgstr+ should include both
+ # binary message with this method. +msgstr+ should include both
# the message headers and body.
#
# +from_addr+ is a String representing the source mail address.
@@ -852,7 +852,7 @@ module Net
# From: john@example.com
# To: betty@example.com
# Subject: I found a bug
- #
+ #
# Check vm.c:58879.
# EndMessage
#
diff --git a/lib/net/telnet.rb b/lib/net/telnet.rb
index 67fd656c63..98285a944b 100644
--- a/lib/net/telnet.rb
+++ b/lib/net/telnet.rb
@@ -1,7 +1,7 @@
# = net/telnet.rb - Simple Telnet Client Library
-#
+#
# Author:: Wakou Aoyama <wakou@ruby-lang.org>
-# Documentation:: William Webber and Wakou Aoyama
+# Documentation:: William Webber and Wakou Aoyama
#
# This file holds the class Net::Telnet, which provides client-side
# telnet functionality.
@@ -13,7 +13,7 @@ require "socket"
require "delegate"
require "timeout"
require "English"
-
+
module Net
#
@@ -50,11 +50,11 @@ module Net
# have to handle authentication yourself.
#
# For some protocols, it will be possible to specify the +Prompt+
- # option once when you create the Telnet object and use #cmd() calls;
+ # option once when you create the Telnet object and use #cmd() calls;
# for others, you will have to specify the response sequence to
# look for as the Match option to every #cmd() call, or call
- # #puts() and #waitfor() directly; for yet others, you will have
- # to use #sysread() instead of #waitfor() and parse server
+ # #puts() and #waitfor() directly; for yet others, you will have
+ # to use #sysread() instead of #waitfor() and parse server
# responses yourself.
#
# It is worth noting that when you create a new Net::Telnet object,
@@ -63,21 +63,21 @@ module Net
# to already open sockets, or to any read-write IO object. This
# can be useful, for instance, for setting up a test fixture for
# unit testing.
- #
+ #
# == Examples
- #
+ #
# === Log in and send a command, echoing all output to stdout
- #
+ #
# localhost = Net::Telnet::new("Host" => "localhost",
# "Timeout" => 10,
# "Prompt" => /[$%#>] \z/n)
# localhost.login("username", "password") { |c| print c }
# localhost.cmd("command") { |c| print c }
# localhost.close
- #
- #
+ #
+ #
# === Check a POP server to see if you have mail
- #
+ #
# pop = Net::Telnet::new("Host" => "your_destination_host_here",
# "Port" => 110,
# "Telnetmode" => false,
@@ -97,73 +97,73 @@ module Net
# :stopdoc:
IAC = 255.chr # "\377" # "\xff" # interpret as command
- DONT = 254.chr # "\376" # "\xfe" # you are not to use option
- DO = 253.chr # "\375" # "\xfd" # please, you use option
- WONT = 252.chr # "\374" # "\xfc" # I won't use option
- WILL = 251.chr # "\373" # "\xfb" # I will use option
- SB = 250.chr # "\372" # "\xfa" # interpret as subnegotiation
- GA = 249.chr # "\371" # "\xf9" # you may reverse the line
- EL = 248.chr # "\370" # "\xf8" # erase the current line
- EC = 247.chr # "\367" # "\xf7" # erase the current character
- AYT = 246.chr # "\366" # "\xf6" # are you there
- AO = 245.chr # "\365" # "\xf5" # abort output--but let prog finish
- IP = 244.chr # "\364" # "\xf4" # interrupt process--permanently
- BREAK = 243.chr # "\363" # "\xf3" # break
- DM = 242.chr # "\362" # "\xf2" # data mark--for connect. cleaning
- NOP = 241.chr # "\361" # "\xf1" # nop
- SE = 240.chr # "\360" # "\xf0" # end sub negotiation
- EOR = 239.chr # "\357" # "\xef" # end of record (transparent mode)
- ABORT = 238.chr # "\356" # "\xee" # Abort process
- SUSP = 237.chr # "\355" # "\xed" # Suspend process
- EOF = 236.chr # "\354" # "\xec" # End of file
- SYNCH = 242.chr # "\362" # "\xf2" # for telfunc calls
-
- OPT_BINARY = 0.chr # "\000" # "\x00" # Binary Transmission
- OPT_ECHO = 1.chr # "\001" # "\x01" # Echo
- OPT_RCP = 2.chr # "\002" # "\x02" # Reconnection
- OPT_SGA = 3.chr # "\003" # "\x03" # Suppress Go Ahead
- OPT_NAMS = 4.chr # "\004" # "\x04" # Approx Message Size Negotiation
- OPT_STATUS = 5.chr # "\005" # "\x05" # Status
- OPT_TM = 6.chr # "\006" # "\x06" # Timing Mark
- OPT_RCTE = 7.chr # "\a" # "\x07" # Remote Controlled Trans and Echo
- OPT_NAOL = 8.chr # "\010" # "\x08" # Output Line Width
- OPT_NAOP = 9.chr # "\t" # "\x09" # Output Page Size
- OPT_NAOCRD = 10.chr # "\n" # "\x0a" # Output Carriage-Return Disposition
- OPT_NAOHTS = 11.chr # "\v" # "\x0b" # Output Horizontal Tab Stops
- OPT_NAOHTD = 12.chr # "\f" # "\x0c" # Output Horizontal Tab Disposition
- OPT_NAOFFD = 13.chr # "\r" # "\x0d" # Output Formfeed Disposition
- OPT_NAOVTS = 14.chr # "\016" # "\x0e" # Output Vertical Tabstops
- OPT_NAOVTD = 15.chr # "\017" # "\x0f" # Output Vertical Tab Disposition
- OPT_NAOLFD = 16.chr # "\020" # "\x10" # Output Linefeed Disposition
- OPT_XASCII = 17.chr # "\021" # "\x11" # Extended ASCII
- OPT_LOGOUT = 18.chr # "\022" # "\x12" # Logout
- OPT_BM = 19.chr # "\023" # "\x13" # Byte Macro
- OPT_DET = 20.chr # "\024" # "\x14" # Data Entry Terminal
- OPT_SUPDUP = 21.chr # "\025" # "\x15" # SUPDUP
- OPT_SUPDUPOUTPUT = 22.chr # "\026" # "\x16" # SUPDUP Output
- OPT_SNDLOC = 23.chr # "\027" # "\x17" # Send Location
- OPT_TTYPE = 24.chr # "\030" # "\x18" # Terminal Type
- OPT_EOR = 25.chr # "\031" # "\x19" # End of Record
- OPT_TUID = 26.chr # "\032" # "\x1a" # TACACS User Identification
- OPT_OUTMRK = 27.chr # "\e" # "\x1b" # Output Marking
- OPT_TTYLOC = 28.chr # "\034" # "\x1c" # Terminal Location Number
- OPT_3270REGIME = 29.chr # "\035" # "\x1d" # Telnet 3270 Regime
- OPT_X3PAD = 30.chr # "\036" # "\x1e" # X.3 PAD
- OPT_NAWS = 31.chr # "\037" # "\x1f" # Negotiate About Window Size
- OPT_TSPEED = 32.chr # " " # "\x20" # Terminal Speed
- OPT_LFLOW = 33.chr # "!" # "\x21" # Remote Flow Control
- OPT_LINEMODE = 34.chr # "\"" # "\x22" # Linemode
- OPT_XDISPLOC = 35.chr # "#" # "\x23" # X Display Location
- OPT_OLD_ENVIRON = 36.chr # "$" # "\x24" # Environment Option
- OPT_AUTHENTICATION = 37.chr # "%" # "\x25" # Authentication Option
- OPT_ENCRYPT = 38.chr # "&" # "\x26" # Encryption Option
- OPT_NEW_ENVIRON = 39.chr # "'" # "\x27" # New Environment Option
- OPT_EXOPL = 255.chr # "\377" # "\xff" # Extended-Options-List
-
- NULL = "\000"
- CR = "\015"
- LF = "\012"
- EOL = CR + LF
+ DONT = 254.chr # "\376" # "\xfe" # you are not to use option
+ DO = 253.chr # "\375" # "\xfd" # please, you use option
+ WONT = 252.chr # "\374" # "\xfc" # I won't use option
+ WILL = 251.chr # "\373" # "\xfb" # I will use option
+ SB = 250.chr # "\372" # "\xfa" # interpret as subnegotiation
+ GA = 249.chr # "\371" # "\xf9" # you may reverse the line
+ EL = 248.chr # "\370" # "\xf8" # erase the current line
+ EC = 247.chr # "\367" # "\xf7" # erase the current character
+ AYT = 246.chr # "\366" # "\xf6" # are you there
+ AO = 245.chr # "\365" # "\xf5" # abort output--but let prog finish
+ IP = 244.chr # "\364" # "\xf4" # interrupt process--permanently
+ BREAK = 243.chr # "\363" # "\xf3" # break
+ DM = 242.chr # "\362" # "\xf2" # data mark--for connect. cleaning
+ NOP = 241.chr # "\361" # "\xf1" # nop
+ SE = 240.chr # "\360" # "\xf0" # end sub negotiation
+ EOR = 239.chr # "\357" # "\xef" # end of record (transparent mode)
+ ABORT = 238.chr # "\356" # "\xee" # Abort process
+ SUSP = 237.chr # "\355" # "\xed" # Suspend process
+ EOF = 236.chr # "\354" # "\xec" # End of file
+ SYNCH = 242.chr # "\362" # "\xf2" # for telfunc calls
+
+ OPT_BINARY = 0.chr # "\000" # "\x00" # Binary Transmission
+ OPT_ECHO = 1.chr # "\001" # "\x01" # Echo
+ OPT_RCP = 2.chr # "\002" # "\x02" # Reconnection
+ OPT_SGA = 3.chr # "\003" # "\x03" # Suppress Go Ahead
+ OPT_NAMS = 4.chr # "\004" # "\x04" # Approx Message Size Negotiation
+ OPT_STATUS = 5.chr # "\005" # "\x05" # Status
+ OPT_TM = 6.chr # "\006" # "\x06" # Timing Mark
+ OPT_RCTE = 7.chr # "\a" # "\x07" # Remote Controlled Trans and Echo
+ OPT_NAOL = 8.chr # "\010" # "\x08" # Output Line Width
+ OPT_NAOP = 9.chr # "\t" # "\x09" # Output Page Size
+ OPT_NAOCRD = 10.chr # "\n" # "\x0a" # Output Carriage-Return Disposition
+ OPT_NAOHTS = 11.chr # "\v" # "\x0b" # Output Horizontal Tab Stops
+ OPT_NAOHTD = 12.chr # "\f" # "\x0c" # Output Horizontal Tab Disposition
+ OPT_NAOFFD = 13.chr # "\r" # "\x0d" # Output Formfeed Disposition
+ OPT_NAOVTS = 14.chr # "\016" # "\x0e" # Output Vertical Tabstops
+ OPT_NAOVTD = 15.chr # "\017" # "\x0f" # Output Vertical Tab Disposition
+ OPT_NAOLFD = 16.chr # "\020" # "\x10" # Output Linefeed Disposition
+ OPT_XASCII = 17.chr # "\021" # "\x11" # Extended ASCII
+ OPT_LOGOUT = 18.chr # "\022" # "\x12" # Logout
+ OPT_BM = 19.chr # "\023" # "\x13" # Byte Macro
+ OPT_DET = 20.chr # "\024" # "\x14" # Data Entry Terminal
+ OPT_SUPDUP = 21.chr # "\025" # "\x15" # SUPDUP
+ OPT_SUPDUPOUTPUT = 22.chr # "\026" # "\x16" # SUPDUP Output
+ OPT_SNDLOC = 23.chr # "\027" # "\x17" # Send Location
+ OPT_TTYPE = 24.chr # "\030" # "\x18" # Terminal Type
+ OPT_EOR = 25.chr # "\031" # "\x19" # End of Record
+ OPT_TUID = 26.chr # "\032" # "\x1a" # TACACS User Identification
+ OPT_OUTMRK = 27.chr # "\e" # "\x1b" # Output Marking
+ OPT_TTYLOC = 28.chr # "\034" # "\x1c" # Terminal Location Number
+ OPT_3270REGIME = 29.chr # "\035" # "\x1d" # Telnet 3270 Regime
+ OPT_X3PAD = 30.chr # "\036" # "\x1e" # X.3 PAD
+ OPT_NAWS = 31.chr # "\037" # "\x1f" # Negotiate About Window Size
+ OPT_TSPEED = 32.chr # " " # "\x20" # Terminal Speed
+ OPT_LFLOW = 33.chr # "!" # "\x21" # Remote Flow Control
+ OPT_LINEMODE = 34.chr # "\"" # "\x22" # Linemode
+ OPT_XDISPLOC = 35.chr # "#" # "\x23" # X Display Location
+ OPT_OLD_ENVIRON = 36.chr # "$" # "\x24" # Environment Option
+ OPT_AUTHENTICATION = 37.chr # "%" # "\x25" # Authentication Option
+ OPT_ENCRYPT = 38.chr # "&" # "\x26" # Encryption Option
+ OPT_NEW_ENVIRON = 39.chr # "'" # "\x27" # New Environment Option
+ OPT_EXOPL = 255.chr # "\377" # "\xff" # Extended-Options-List
+
+ NULL = "\000"
+ CR = "\015"
+ LF = "\012"
+ EOL = CR + LF
REVISION = '$Id$'
# :startdoc:
@@ -174,13 +174,13 @@ module Net
# provided: see below). If a block is provided, it is yielded
# status messages on the attempt to connect to the server, of
# the form:
- #
+ #
# Trying localhost...
# Connected to localhost.
#
# +options+ is a hash of options. The following example lists
# all options and their default values.
- #
+ #
# host = Net::Telnet::new(
# "Host" => "localhost", # default: "localhost"
# "Port" => 23, # default: 23
@@ -198,16 +198,16 @@ module Net
#
# The options have the following meanings:
#
- # Host:: the hostname or IP address of the host to connect to, as a String.
+ # Host:: the hostname or IP address of the host to connect to, as a String.
# Defaults to "localhost".
#
# Port:: the port to connect to. Defaults to 23.
#
- # Binmode:: if false (the default), newline substitution is performed.
+ # Binmode:: if false (the default), newline substitution is performed.
# Outgoing LF is
# converted to CRLF, and incoming CRLF is converted to LF. If
# true, this substitution is not performed. This value can
- # also be set with the #binmode() method. The
+ # also be set with the #binmode() method. The
# outgoing conversion only applies to the #puts() and #print()
# methods, not the #write() method. The precise nature of
# the newline conversion is also affected by the telnet options
@@ -217,13 +217,13 @@ module Net
# and all received traffic to. In the case of a proper
# Telnet session, this will include the client input as
# echoed by the host; otherwise, it only includes server
- # responses. Output is appended verbatim to this file.
+ # responses. Output is appended verbatim to this file.
# By default, no output log is kept.
#
# Dump_log:: as for Output_log, except that output is written in hexdump
# format (16 bytes per line as hex pairs, followed by their
# printable equivalent), with connection status messages
- # preceded by '#', sent traffic preceded by '>', and
+ # preceded by '#', sent traffic preceded by '>', and
# received traffic preceded by '<'. By default, not dump log
# is kept.
#
@@ -233,7 +233,7 @@ module Net
# ready to receive a new command. By default, this regular
# expression is /[$%#>] \z/n.
#
- # Telnetmode:: a boolean value, true by default. In telnet mode,
+ # Telnetmode:: a boolean value, true by default. In telnet mode,
# traffic received from the host is parsed for special
# command sequences, and these sequences are escaped
# in outgoing traffic sent using #puts() or #print()
@@ -255,11 +255,11 @@ module Net
# minutes), but other attempts to read data from the host
# will hand indefinitely if no data is forthcoming.
#
- # Waittime:: the amount of time to wait after seeing what looks like a
+ # Waittime:: the amount of time to wait after seeing what looks like a
# prompt (that is, received data that matches the Prompt
# option regular expression) to see if more data arrives.
# If more data does arrive in this time, Net::Telnet assumes
- # that what it saw was not really a prompt. This is to try to
+ # that what it saw was not really a prompt. This is to try to
# avoid false matches, but it can also lead to missing real
# prompts (if, for instance, a background process writes to
# the terminal soon after the prompt is displayed). By
@@ -267,12 +267,12 @@ module Net
#
# Proxy:: a proxy object to used instead of opening a direct connection
# to the host. Must be either another Net::Telnet object or
- # an IO object. If it is another Net::Telnet object, this
+ # an IO object. If it is another Net::Telnet object, this
# instance will use that one's socket for communication. If an
# IO object, it is used directly for communication. Any other
# kind of object will cause an error to be raised.
#
- def initialize(options) # :yield: mesg
+ def initialize(options) # :yield: mesg
@options = options
@options["Host"] = "localhost" unless @options.has_key?("Host")
@options["Port"] = 23 unless @options.has_key?("Port")
@@ -280,7 +280,7 @@ module Net
@options["Timeout"] = 10 unless @options.has_key?("Timeout")
@options["Waittime"] = 0 unless @options.has_key?("Waittime")
unless @options.has_key?("Binmode")
- @options["Binmode"] = false
+ @options["Binmode"] = false
else
unless (true == @options["Binmode"] or false == @options["Binmode"])
raise ArgumentError, "Binmode option must be true or false"
@@ -288,7 +288,7 @@ module Net
end
unless @options.has_key?("Telnetmode")
- @options["Telnetmode"] = true
+ @options["Telnetmode"] = true
else
unless (true == @options["Telnetmode"] or false == @options["Telnetmode"])
raise ArgumentError, "Telnetmode option must be true or false"
@@ -374,7 +374,7 @@ module Net
# The socket the Telnet object is using. Note that this object becomes
# a delegate of the Telnet object, so normally you invoke its methods
# directly on the Telnet object.
- attr :sock
+ attr :sock
# Set telnet command interpretation on (+mode+ == true) or off
# (+mode+ == false), or return the current value (+mode+ not
@@ -408,7 +408,7 @@ module Net
def binmode(mode = nil)
case mode
when nil
- @options["Binmode"]
+ @options["Binmode"]
when true, false
@options["Binmode"] = mode
else
@@ -428,7 +428,7 @@ module Net
# Preprocess received data from the host.
#
# Performs newline conversion and detects telnet command sequences.
- # Called automatically by #waitfor(). You should only use this
+ # Called automatically by #waitfor(). You should only use this
# method yourself if you have read input directly using sysread()
# or similar, and even then only if in telnet mode.
def preprocess(string)
@@ -494,9 +494,9 @@ module Net
# Read data from the host until a certain sequence is matched.
#
# If a block is given, the received data will be yielded as it
- # is read in (not necessarily all in one go), or nil if EOF
+ # is read in (not necessarily all in one go), or nil if EOF
# occurs before any data is received. Whether a block is given
- # or not, all data read will be returned in a single string, or again
+ # or not, all data read will be returned in a single string, or again
# nil if EOF occurs before any data is received. Note that
# received data includes the matched sequence we were looking for.
#
@@ -510,7 +510,7 @@ module Net
# into a regular expression. Used only if Match and
# Prompt are not specified.
# Timeout:: the number of seconds to wait for data from the host
- # before raising a TimeoutError. If set to false,
+ # before raising a TimeoutError. If set to false,
# no timeout will occur. If not specified, the
# Timeout option value specified when this instance
# was created will be used, or, failing that, the
@@ -527,7 +527,7 @@ module Net
# EOFError will be raised. Otherwise, defaults to the old
# behaviour that the function will return whatever data
# has been received already, or nil if nothing was received.
- #
+ #
def waitfor(options) # :yield: recvdata
time_out = @options["Timeout"]
waittime = @options["Waittime"]
@@ -622,7 +622,7 @@ module Net
# Sends a string to the host.
#
# This does _not_ automatically append a newline to the string. Embedded
- # newlines may be converted and telnet command sequences escaped
+ # newlines may be converted and telnet command sequences escaped
# depending upon the values of telnetmode, binmode, and telnet options
# set by the host.
def print(string)
@@ -657,7 +657,7 @@ module Net
# data until is sees the prompt or other matched sequence.
#
# If a block is given, the received data will be yielded to it as
- # it is read in. Whether a block is given or not, the received data
+ # it is read in. Whether a block is given or not, the received data
# will be return as a string. Note that the received data includes
# the prompt and in most cases the host's echo of our command.
#
@@ -702,7 +702,7 @@ module Net
#
# The username and password can either be provided as two string
# arguments in that order, or as a hash with keys "Name" and
- # "Password".
+ # "Password".
#
# This method looks for the strings "login" and "Password" from the
# host to determine when to send the username and password. If the