I’d like to only get page headers for a url without downloading the page content. This is what I’m using right now:
...
URL targetUrl = new URL( urlValue );
HttpURLConnection conn = (HttpURLConnection) targetUrl.openConnection();
String value = conn.getHeaderField(0);
...
I’m not sure if this is getting the headers then quitting or what its doing.
Send a
HEADrequest instead of aGETrequest (which is the default method).Otherwise the full response body is been returned.