instance method
Net::HTTP#request_get
(::String path, ?::Net::headers initheader) ?{ (::Net::HTTPResponse response) -> void } -> ::Net::HTTPResponse
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>
See also
#request
#request_head
#read_timeout=
#request_post
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0