class Net::HTTP::Get - Documentation for Ruby 4.1
Description: class Net::HTTP::Get: en. wikipedia.
Keywords: ruby,class,Net::HTTP::Get

🔍

No recent searches

# class Net::HTTP::Get

Class for representing HTTP method GET:

    require 'net/http'
    uri = URI('http://example.com')
    hostname = uri.hostname # => "example.com"
    req = Net::HTTP::Get.new(uri) # => #<Net::HTTP::Get GET>
    res = Net::HTTP.start(hostname) do |http|
      http.request(req)
    end

See Request Headers.

Properties:

- Request body: optional.

- Response body: yes.

- Safe: yes.

- Idempotent: yes.

- Cacheable: yes.

Related:

- `Net::HTTP.get`: sends `GET` request, returns response body.

- `Net::HTTP#get`: sends `GET` request, returns response object.