Skip to content

Instantly share code, notes, and snippets.

@sapereau83
Created November 19, 2014 15:03
Show Gist options
  • Select an option

  • Save sapereau83/c5da45c39cb69e73ba18 to your computer and use it in GitHub Desktop.

Select an option

Save sapereau83/c5da45c39cb69e73ba18 to your computer and use it in GitHub Desktop.
Ruby Net::HTTP Get header without body from an HTTP request
require "net/http"
uri = URI('YOUR URL')
req = Net::HTTP::Head.new(uri)
res = Net::HTTP.start(uri.hostname, uri.port) do |http|
http.request(req)
end
p res # => #<Net::HTTPOK 200 OK readbody=true>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment