In a Rails app, I’d like to make a HTTP HEAD request for a resource (a user-provided URL), to make sure that it exists. I’d also like a timeout, to ensure that the method fails after spending a reasonable period of time waiting. What is the most straightforward way to accomplish this (using the standard library, if possible)?
Share
Try this snippet:
Hope this is what you’re looking for.
UPDATE
Because there is
headmethod that looks likeYou can also use this snippet: