What's the fastest way to get a URLs status code using HttpClient

http-status-codes, httpclient, java, performance

Solution

Use the HEAD call. It's basically a GET call where the server does not return a body. Example from their documentation:

HeadMethod head = new HeadMethod("http://jakarta.apache.org");
// execute the method and handle any error responses.
...
// Retrieve all the headers.
Header[] headers = head.getResponseHeaders();

// Retrieve just the last modified header value.
String lastModified = head.getResponseHeader("last-modified").getValue();

Problem

What is the fastest method of getting a URLs status using HttpClient? I don't want to download the page/file, I just want to know if the page/file exists?(If it's a redirect I want it to follow the redirect)

Original source