* Do a HEAD call on the URL.
* Look for the header "Content-Description" = "ncstream" or "dods".
*/
static private ServiceType disambiguateHttp(String location) throws IOException {
HTTPSession session = new HTTPSession();
// have to do dods first
ServiceType result = checkIfDods(session,location);
if (result != null)
return result;
HTTPMethod method = null;
try {
method = session.newMethodHead(location);
int statusCode = method.execute();
if (statusCode >= 300) {
if (statusCode == 401)
throw new IOException("Unauthorized to open dataset " + location);
else
throw new IOException(location + " is not a valid URL, return status=" + statusCode);
}
Header h = method.getResponseHeader("Content-Description");
if ((h != null) && (h.getValue() != null)) {
String v = h.getValue();
if (v.equalsIgnoreCase("ncstream"))
return ServiceType.CdmRemote;
}
return null;
} finally {
if (session != null) session.close();
}
}