Skip to content

Commit 6da39b0

Browse files
[DOC] Enhanced RDoc for write_timeout (#115)
1 parent b4436ba commit 6da39b0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/net/http.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def HTTP.post_form(url, params)
530530
# \HTTP session management
531531
#
532532

533-
# Returns intger +80+, the default port to use for \HTTP requests:
533+
# Returns integer +80+, the default port to use for \HTTP requests:
534534
#
535535
# Net::HTTP.default_port # => 80
536536
#
@@ -1048,7 +1048,20 @@ def read_timeout=(sec)
10481048
# Sets the write timeout, in seconds, for +self+ to integer +sec+;
10491049
# the initial value is 60.
10501050
#
1051-
# Argument +sec+ must be a non-negative numeric value.
1051+
# Argument +sec+ must be a non-negative numeric value:
1052+
#
1053+
# _uri = uri.dup
1054+
# _uri.path = '/posts'
1055+
# body = 'bar' * 200000
1056+
# data = <<EOF
1057+
# {"title": "foo", "body": "#{body}", "userId": "1"}
1058+
# EOF
1059+
# headers = {'content-type': 'application/json'}
1060+
# http = Net::HTTP.new(hostname)
1061+
# http.post(_uri.path, data, headers)
1062+
# # => #<Net::HTTPCreated 201 Created readbody=true>
1063+
# http.write_timeout = 0
1064+
# http.post(_uri.path, data, headers) # Raises Net::WriteTimeout.
10521065
#
10531066
def write_timeout=(sec)
10541067
@socket.write_timeout = sec if @socket

0 commit comments

Comments
 (0)