End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Net::HTTP#request_get
request_get(path, initheader = nil) { |response| ... }
lib/net/http.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/net/http.rb, line 1421
def request_get(path, initheader = nil, &block) # :yield: +response+
request(Get.new(path, initheader), &block)
end
Sends a GET request to the path. Returns the response as 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.
Returns the response.
This method never raises Net::* exceptions.
Example
response = http.request_get('/index.html') # The entity body is already read in this case. p response['content-type'] puts response.body # Using a block http.request_get('/index.html') {|response| p response['content-type'] response.read_body do |str| # read body now print str end }
See also
#request
#request_head
#read_timeout=
#request_post
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1