@@ -1847,30 +1847,27 @@ def trace(path, initheader = nil)
1847
1847
request ( Trace . new ( path , initheader ) )
1848
1848
end
1849
1849
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.
1852
1852
#
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+.
1857
1855
#
1858
- # Returns the response.
1856
+ # With no block given, returns the response object:
1859
1857
#
1860
- # This method never raises Net::* exceptions.
1858
+ # http = Net::HTTP.new(hostname)
1859
+ # http.request_get('/todos') # => #<Net::HTTPOK 200 OK readbody=true>
1861
1860
#
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:
1866
1863
#
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>
1874
1871
#
1875
1872
def request_get ( path , initheader = nil , &block ) # :yield: +response+
1876
1873
request ( Get . new ( path , initheader ) , &block )
0 commit comments