instance method
Net::HTTPSession#head
head(path, initheader = nil)
lib/net/http.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/net/http.rb, line 2037
def head(path, initheader = nil)
request(Head.new(path, initheader))
end
Sends a HEAD request to the server; returns an instance of a subclass of Net::HTTPResponse.
The request is based on the Net::HTTP::Head object created from string path and initial headers hash initheader:
Example
res = http.head('/todos/1') # => #<Net::HTTPOK 200 OK readbody=true> res.body # => nil res.to_hash.take(3) # => [["date", ["Wed, 15 Feb 2023 15:25:42 GMT"]], ["content-type", ["application/json; charset=utf-8"]], ["connection", ["close"]]]