cdm/src/main/java/ucar/nc2/dataset/DatasetUrl.java
static private ServiceType checkIfDods(String location) throws IOException {
    int len = location.length();
    // Strip off any trailing .dds, .das, or .dods
    if (location.endsWith(".dds"))
      location = location.substring(0, len - ".dds".length());
    if (location.endsWith(".das"))
      location = location.substring(0, len - ".das".length());
    if (location.endsWith(".dods"))
      location = location.substring(0, len - ".dods".length());

    // Opendap assumes that the caller has properly escaped the url
    try (
            // For some reason, the head method is not using credentials
            // method = session.newMethodHead(location + ".dds");
            HTTPMethod method = HTTPFactory.Get(location + ".dds")) {

      int status = method.execute();
      if (status == 200) {
        Header h = method.getResponseHeader("Content-Description");
        if ((h != null) && (h.getValue() != null)) {
          String v = h.getValue();
          if (v.equalsIgnoreCase("dods-dds") || v.equalsIgnoreCase("dods_dds"))
            return ServiceType.OPENDAP;
          else
            throw new IOException("OPeNDAP Server Error= " + method.getResponseAsString());
        }
      }
      if (status == HttpStatus.SC_UNAUTHORIZED || status == HttpStatus.SC_FORBIDDEN)
        throw new IOException("Unauthorized to open dataset " + location);

      // not dods
      return null;
    }
  }
static private ServiceType checkIfDods(String location) throws IOException {
    int len = location.length();
    // Strip off any trailing .dds, .das, or .dods
    if (location.endsWith(".dds"))
      location = location.substring(0, len - ".dds".length());
    if (location.endsWith(".das"))
      location = location.substring(0, len - ".das".length());
    if (location.endsWith(".dods"))
      location = location.substring(0, len - ".dods".length());

    // Opendap assumes that the caller has properly escaped the url
    try (
            // For some reason, the head method is not using credentials
            // method = session.newMethodHead(location + ".dds");
            HTTPMethod method = HTTPFactory.Get(location + ".dds")) {

      int status = method.execute();
      if (status == 200) {
        Header h = method.getResponseHeader("Content-Description");
        if ((h != null) && (h.getValue() != null)) {
          String v = h.getValue();
          if (v.equalsIgnoreCase("dods-dds") || v.equalsIgnoreCase("dods_dds"))
            return ServiceType.OPENDAP;
          else
            throw new IOException("OPeNDAP Server Error= " + method.getResponseAsString());
        }
      }
      if (status == HttpStatus.SC_UNAUTHORIZED || status == HttpStatus.SC_FORBIDDEN)
        throw new IOException("Unauthorized to open dataset " + location);

      // not dods
      return null;
    }
  }
static private ServiceType checkIfDods ( String location ) throws IOException { int len = location . length ( ) ; // Strip off any trailing .dds, .das, or .dods if ( location . endsWith ( ".dds" ) ) location = location . substring ( 0 , len - ".dds" . length ( ) ) ; if ( location . endsWith ( ".das" ) ) location = location . substring ( 0 , len - ".das" . length ( ) ) ; if ( location . endsWith ( ".dods" ) ) location = location . substring ( 0 , len - ".dods" . length ( ) ) ; // Opendap assumes that the caller has properly escaped the url try ( // For some reason, the head method is not using credentials // method = session.newMethodHead(location + ".dds"); HTTPMethod method = HTTPFactory . Get ( location + ".dds" ) ) { int status = method . execute ( ) ; if ( status == 200 ) { Header h = method . getResponseHeader ( "Content-Description" ) ; if ( ( h != null ) && ( h . getValue ( ) != null ) ) { String v = h . getValue ( ) ; if ( v . equalsIgnoreCase ( "dods-dds" ) || v . equalsIgnoreCase ( "dods_dds" ) ) return ServiceType . OPENDAP ; else throw new IOException ( "OPeNDAP Server Error= " + method . getResponseAsString ( ) ) ; } } if ( status == HttpStatus . SC_UNAUTHORIZED || status == HttpStatus . SC_FORBIDDEN ) throw new IOException ( "Unauthorized to open dataset " + location ) ; // not dods return null ; } }
not sure what other opendap servers do, so fall back on check for dds
not sure what other opendap servers do so fall back on check for dds