open-uri icon indicating copy to clipboard operation
open-uri copied to clipboard

Feature: HEAD request with open?

Open svoop opened this issue 4 years ago • 0 comments

It's quite a common task to check whether a URI leads to a dead end or not. For a "simple" HEAD request, handling the many edge cases (SSL, proxy etc) with net/http is very cumbersome and this excellent gem implements already most of these, therefore ...

Would you consider adding HEAD requests to open-uri. Possible API:

URI.open?("http://www.ruby-lang.org/")

The HTTP status of the HEAD request should be interpreted as follows:

  • Any 5xx status raises an exception: Server error means it's impossible to tell whether the URI is okay.
  • Any 4xx status returns false: The URI is not valid.
  • Any other status returns true: The URI is valid.

svoop avatar Dec 29 '21 18:12 svoop