@@ -1847,30 +1847,27 @@ def trace(path, initheader = nil)
18471847 request ( Trace . new ( path , initheader ) )
18481848 end
18491849
1850- # Sends a GET request to the +path+.
1851- # Returns the response as a Net::HTTPResponse object.
1850+ # Sends a GET request to the server;
1851+ # forms the response into a Net::HTTPResponse object.
18521852 #
1853- # When called with a block, passes an HTTPResponse object to the block.
1854- # The body of the response will not have been read yet;
1855- # the block can process it using HTTPResponse#read_body,
1856- # if desired.
1853+ # The request is based on the Net::HTTP::Get object
1854+ # created from string +path+ and initial headers hash +initheader+.
18571855 #
1858- # Returns the response.
1856+ # With no block given, returns the response object:
18591857 #
1860- # This method never raises Net::* exceptions.
1858+ # http = Net::HTTP.new(hostname)
1859+ # http.request_get('/todos') # => #<Net::HTTPOK 200 OK readbody=true>
18611860 #
1862- # response = http.request_get('/index.html')
1863- # # The entity body is already read in this case.
1864- # p response['content-type']
1865- # puts response.body
1861+ # With a block given, calls the block with the response object
1862+ # and returns the response object:
18661863 #
1867- # # Using a block
1868- # http.request_get('/index.html') {|response|
1869- # p response['content-type']
1870- # response.read_body do |str| # read body now
1871- # print str
1872- # end
1873- # }
1864+ # http.request_get('/todos') do |res|
1865+ # p res
1866+ # end # => #<Net::HTTPOK 200 OK readbody=true>
1867+ #
1868+ # Output:
1869+ #
1870+ # #<Net::HTTPOK 200 OK readbody=false>
18741871 #
18751872 def request_get ( path , initheader = nil , &block ) # :yield: +response+
18761873 request ( Get . new ( path , initheader ) , &block )
0 commit comments