-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DOC] Enhanced RDoc for Net:HTTP #124
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1090,7 +1090,7 @@ def write_timeout=(sec) | |
end | ||
|
||
# Returns the continue timeout value. | ||
# See Net::HTTP.continue_timeout=. | ||
# See Net::HTTP.continue_timeout=. | ||
# | ||
attr_reader :continue_timeout | ||
|
||
|
@@ -1847,30 +1847,28 @@ def trace(path, initheader = nil) | |
request(Trace.new(path, initheader)) | ||
end | ||
|
||
# Sends a GET request to the +path+. | ||
# Returns the response as a Net::HTTPResponse object. | ||
# Sends a GET request to the server; | ||
# forms the response into a Net::HTTPResponse object. | ||
# | ||
# When called with a block, passes an HTTPResponse object to the block. | ||
# The body of the response will not have been read yet; | ||
# the block can process it using HTTPResponse#read_body, | ||
# if desired. | ||
# The request is based on the Net::HTTP::Get object | ||
# created from string +path+ and initial headers hash +initheader+. | ||
# | ||
# Returns the response. | ||
# With no block given, returns the response object (with the body already read): | ||
# | ||
# This method never raises Net::* exceptions. | ||
# http = Net::HTTP.new(hostname) | ||
# http.request_get('/todos') # => #<Net::HTTPOK 200 OK readbody=true> | ||
# | ||
# response = http.request_get('/index.html') | ||
# # The entity body is already read in this case. | ||
# p response['content-type'] | ||
# puts response.body | ||
# With a block given, calls the block with the response object | ||
# (with the body _not_ already read), | ||
# and returns the response object (_with_ the body already read): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think talking about whether the body has been read is important. It's an internal state that isn't publicly exposed (except in the output string of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed. |
||
# | ||
# # Using a block | ||
# http.request_get('/index.html') {|response| | ||
# p response['content-type'] | ||
# response.read_body do |str| # read body now | ||
# print str | ||
# end | ||
# } | ||
# http.request_get('/todos') do |res| | ||
# p res | ||
# end # => #<Net::HTTPOK 200 OK readbody=true> | ||
# | ||
# Output: | ||
# | ||
# #<Net::HTTPOK 200 OK readbody=false> | ||
# | ||
def request_get(path, initheader = nil, &block) # :yield: +response+ | ||
request(Get.new(path, initheader), &block) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the trailing space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.