instance method
Net::HTTPSession#request_get
request_get(path, initheader = nil) { |response| ... }
lib/net/http.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/net/http.rb, line 2280
def request_get(path, initheader = nil, &block) # :yield: +response+
request(Get.new(path, initheader), &block)
end
Sends a GET request to the server; forms the response into a Net::HTTPResponse object.
The request is based on the Net::HTTP::Get object created from string path and initial headers hash initheader.
With no block given, returns the response object:
Example
http = Net::HTTP.new(hostname) http.request_get('/todos') # => #<Net::HTTPOK 200 OK readbody=true>
With a block given, calls the block with the response object and returns the response object:
Example
http.request_get('/todos') do |res| p res end # => #<Net::HTTPOK 200 OK readbody=true>
Output:
Example
#<Net::HTTPOK 200 OK readbody=false>