Method: Gem::Net::HTTP#head
- Defined in:
- lib/rubygems/vendor/net-http/lib/net/http.rb
#head(path, initheader = nil) ⇒ Object
Sends a HEAD request to the server; returns an instance of a subclass of Gem::Net::HTTPResponse.
The request is based on the Gem::Net::HTTP::Head object created from string path
and initial headers hash initheader
:
res = http.head('/todos/1') # => #<Gem::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"]]]
2011 2012 2013 |
# File 'lib/rubygems/vendor/net-http/lib/net/http.rb', line 2011 def head(path, initheader = nil) request(Head.new(path, initheader)) end |