Skip to content

Commit 05f016c

Browse files
BurdetteLamarmatzbot
authored andcommitted
[ruby/net-http] [DOC] Enhanced RDoc for Net::HTTP
(ruby/net-http#126) ruby/net-http@4700d0660b
1 parent f471f46 commit 05f016c

File tree

2 files changed

+55
-34
lines changed

2 files changed

+55
-34
lines changed

lib/net/http.rb

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class HTTPHeaderSyntaxError < StandardError; end
368368
# http.proxy_user # => "pname"
369369
# http.proxy_pass # => "ppass"
370370
#
371-
# === Proxy Using <tt>ENV['http_proxy']</tt>
371+
# === Proxy Using '<tt>ENV['http_proxy']</tt>'
372372
#
373373
# When environment variable <tt>'http_proxy'</tt>
374374
# is set to a \URI string,
@@ -826,7 +826,7 @@ def HTTP.new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_p
826826
# Creates a new \Net::HTTP object for the specified server address,
827827
# without opening the TCP connection or initializing the \HTTP session.
828828
# The +address+ should be a DNS hostname or IP address.
829-
def initialize(address, port = nil)
829+
def initialize(address, port = nil) # :nodoc:
830830
@address = address
831831
@port = (port || HTTP.default_port)
832832
@ipaddr = nil
@@ -926,21 +926,22 @@ def set_debug_output(output)
926926
@debug_output = output
927927
end
928928

929-
# The DNS host name or IP address to connect to.
929+
# Returns the string host name or host IP given as argument +address+ in ::new.
930930
attr_reader :address
931931

932-
# The port number to connect to.
932+
# Returns the integer port number given as argument +port+ in ::new.
933933
attr_reader :port
934934

935-
# The local host used to establish the connection.
935+
# Sets or returns the string local host used to establish the connection;
936+
# initially +nil+.
936937
attr_accessor :local_host
937938

938-
# The local port used to establish the connection.
939+
# Sets or returns the integer local port used to establish the connection;
940+
# initially +nil+.
939941
attr_accessor :local_port
940942

941-
# The encoding to use for the response body. If Encoding, uses the
942-
# specified encoding. If other true value, tries to detect the response
943-
# body encoding.
943+
# Returns the encoding to use for the response body;
944+
# see #response_body_encoding=.
944945
attr_reader :response_body_encoding
945946

946947
# Sets the encoding to be used for the response body;
@@ -966,10 +967,25 @@ def response_body_encoding=(value)
966967
@response_body_encoding = value
967968
end
968969

970+
# Sets whether to determine the proxy from environment variable
971+
# '<tt>ENV['http_proxy']</tt>';
972+
# see {Proxy Using ENV['http_proxy']}[rdoc-ref:Net::HTTP@Proxy+Using+-27ENV-5B-27http_proxy-27-5D-27].
969973
attr_writer :proxy_from_env
974+
975+
# Sets the proxy address;
976+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
970977
attr_writer :proxy_address
978+
979+
# Sets the proxy port;
980+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
971981
attr_writer :proxy_port
982+
983+
# Sets the proxy user;
984+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
972985
attr_writer :proxy_user
986+
987+
# Sets the proxy password;
988+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
973989
attr_writer :proxy_pass
974990

975991
# Returns the IP address for the connection.
@@ -1008,23 +1024,21 @@ def ipaddr=(addr)
10081024
@ipaddr = addr
10091025
end
10101026

1011-
# Number of seconds to wait for the connection to open. Any number
1012-
# may be used, including Floats for fractional seconds. If the \HTTP
1013-
# object cannot open a connection in this many seconds, it raises a
1014-
# \Net::OpenTimeout exception. The default value is 60 seconds.
1027+
# Sets or returns the numeric (\Integer or \Float) number of seconds
1028+
# to wait for a connection to open;
1029+
# initially 60.
1030+
# If the connection is not made in the given interval,
1031+
# an exception is raised.
10151032
attr_accessor :open_timeout
10161033

1017-
# Number of seconds to wait for one block to be read (via one read(2)
1018-
# call). Any number may be used, including Floats for fractional
1019-
# seconds. If the \HTTP object cannot read data in this many seconds,
1020-
# it raises a Net::ReadTimeout exception. The default value is 60 seconds.
1034+
# Returns the numeric (\Integer or \Float) number of seconds
1035+
# to wait for one block to be read (via one read(2) call);
1036+
# see #read_timeout=.
10211037
attr_reader :read_timeout
10221038

1023-
# Number of seconds to wait for one block to be written (via one write(2)
1024-
# call). Any number may be used, including Floats for fractional
1025-
# seconds. If the \HTTP object cannot write data in this many seconds,
1026-
# it raises a \Net::WriteTimeout exception. The default value is 60 seconds.
1027-
# \Net::WriteTimeout is not raised on Windows.
1039+
# Returns the numeric (\Integer or \Float) number of seconds
1040+
# to wait for one block to be written (via one write(2) call);
1041+
# see #write_timeout=.
10281042
attr_reader :write_timeout
10291043

10301044
# Sets the maximum number of times to retry an idempotent request in case of
@@ -1047,6 +1061,8 @@ def max_retries=(retries)
10471061
@max_retries = retries
10481062
end
10491063

1064+
# Returns the maximum number of times to retry an idempotent request;
1065+
# see #max_retries=.
10501066
attr_reader :max_retries
10511067

10521068
# Sets the read timeout, in seconds, for +self+ to integer +sec+;
@@ -1089,9 +1105,8 @@ def write_timeout=(sec)
10891105
@write_timeout = sec
10901106
end
10911107

1092-
# Returns the continue timeout value.
1093-
# See Net::HTTP.continue_timeout=.
1094-
#
1108+
# Returns the continue timeout value;
1109+
# see continue_timeout=.
10951110
attr_reader :continue_timeout
10961111

10971112
# Sets the continue timeout value,
@@ -1103,14 +1118,18 @@ def continue_timeout=(sec)
11031118
@continue_timeout = sec
11041119
end
11051120

1106-
# Seconds to reuse the connection of the previous request.
1107-
# If the idle time is less than this Keep-Alive Timeout,
1108-
# \Net::HTTP reuses the TCP/IP socket used by the previous communication.
1109-
# The default value is 2 seconds.
1121+
# Sets or returns the numeric (\Integer or \Float) number of seconds
1122+
# to keep the connection open after a request is sent;
1123+
# initially 2.
1124+
# If a new request is made during the given interval,
1125+
# the still-open connection is used;
1126+
# otherwise the connection will have been closed
1127+
# and a new connection is opened.
11101128
attr_accessor :keep_alive_timeout
11111129

1112-
# Whether to ignore EOF when reading response bodies with defined
1113-
# Content-Length headers. For backwards compatibility, the default is true.
1130+
# Sets or returns whether to ignore end-of-file when reading a response body
1131+
# with <tt>Content-Length</tt> headers;
1132+
# initially +true+.
11141133
attr_accessor :ignore_eof
11151134

11161135
# Returns +true+ if the \HTTP session has been started:
@@ -1133,6 +1152,8 @@ def started?
11331152

11341153
alias active? started? #:nodoc: obsolete
11351154

1155+
# Sets or returns whether to close the connection when the response is empty;
1156+
# initially +false+.
11361157
attr_accessor :close_on_empty_response
11371158

11381159
# Returns +true+ if +self+ uses SSL, +false+ otherwise.
@@ -1171,7 +1192,7 @@ def use_ssl=(flag)
11711192
:@verify_depth,
11721193
:@verify_mode,
11731194
:@verify_hostname,
1174-
]
1195+
] # :nodoc:
11751196
SSL_ATTRIBUTES = [
11761197
:ca_file,
11771198
:ca_path,
@@ -1188,7 +1209,7 @@ def use_ssl=(flag)
11881209
:verify_depth,
11891210
:verify_mode,
11901211
:verify_hostname,
1191-
]
1212+
] # :nodoc:
11921213

11931214
# Sets path of a CA certification file in PEM format.
11941215
#

lib/net/http/status.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@
8080
508 => 'Loop Detected',
8181
510 => 'Not Extended',
8282
511 => 'Network Authentication Required',
83-
}
83+
} # :nodoc:

0 commit comments

Comments
 (0)