class Net::HTTP::Head - Documentation for Ruby 4.0
Description: class Net::HTTP::Head: en. wikipedia.
Keywords: ruby,class,Net::HTTP::Head

🔍

No recent searches

# class Net::HTTP::Head

Class for representing HTTP method HEAD:

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

See Request Headers.

Properties:

- Request body: optional.

- Response body: no.

- Safe: yes.

- Idempotent: yes.

- Cacheable: yes.

Related:

- `Net::HTTP#head`: sends `HEAD` request, returns response object.