tds/src/main/java/thredds/server/cdmremote/CdmRemoteController.java
@RequestMapping(value = "/**", method = RequestMethod.GET)
  public ResponseEntity<String> handleCapabilitiesRequest(HttpServletRequest request, HttpServletResponse response, @RequestParam String req) throws IOException {

    if (!allowedServices.isAllowed(StandardService.cdmRemote))
      throw new ServiceNotAllowed(StandardService.cdmRemote.toString());

    String datasetPath = TdsPathUtils.extractPath(request, "/cdmremote");
    String absPath = getAbsolutePath(request);
    HttpHeaders responseHeaders;

    if (showReq)
      System.out.printf("CdmRemoteController req=%s%n", absPath + "?" + request.getQueryString());
    if (debug)
      System.out.printf(" path=%s%n query=%s%n", datasetPath, request.getQueryString());

    // LOOK heres where we want the Dataset, not the netcdfFile (!)
    try (NetcdfFile ncfile = TdsRequestedDataset.getNetcdfFile(request, response, datasetPath)) {
      if (ncfile == null) return null;  // failed resource control

      responseHeaders = new HttpHeaders();
      responseHeaders.setDate("Last-Modified", TdsRequestedDataset.getLastModified(datasetPath));

      // a request without a parameter is a test to see if this is a valid cdremote endpoint.
      // just setHeader("Content-Description", "ncstream"), no body
      // on client, see DatasetUrl.disambiguateHttp
      if (req == null) {
          response.setContentType(ContentType.binary.getContentHeader());
          response.setHeader("Content-Description", "ncstream");
          return new ResponseEntity<>(null, responseHeaders, HttpStatus.OK);
        }

      switch (req.toLowerCase()) {
        case "form":    // ol
        case "cdl":
          ncfile.setLocation(datasetPath); // hide where the file is stored  LOOK
          String cdl = ncfile.toString();
          responseHeaders.set(ContentType.HEADER, ContentType.text.getContentHeader());
          return new ResponseEntity<>(cdl, responseHeaders, HttpStatus.OK);

        case "ncml":
          String ncml = ncfile.toNcML(absPath);
          responseHeaders.set(ContentType.HEADER, ContentType.xml.getContentHeader());
          return new ResponseEntity<>(ncml, responseHeaders, HttpStatus.OK);

        default:
          return new ResponseEntity<>("Unrecognized request", null, HttpStatus.BAD_REQUEST);
      }
    }
  }
@RequestMapping(value = "/**", method = RequestMethod.GET)
  public ResponseEntity<String> handleCapabilitiesRequest(HttpServletRequest request, HttpServletResponse response, @RequestParam String req) throws IOException {

    if (!allowedServices.isAllowed(StandardService.cdmRemote))
      throw new ServiceNotAllowed(StandardService.cdmRemote.toString());

    String datasetPath = TdsPathUtils.extractPath(request, "/cdmremote");
    String absPath = getAbsolutePath(request);
    HttpHeaders responseHeaders;

    if (showReq)
      System.out.printf("CdmRemoteController req=%s%n", absPath + "?" + request.getQueryString());
    if (debug)
      System.out.printf(" path=%s%n query=%s%n", datasetPath, request.getQueryString());

    // LOOK heres where we want the Dataset, not the netcdfFile (!)
    try (NetcdfFile ncfile = TdsRequestedDataset.getNetcdfFile(request, response, datasetPath)) {
      if (ncfile == null) return null;  // failed resource control

      responseHeaders = new HttpHeaders();
      responseHeaders.setDate("Last-Modified", TdsRequestedDataset.getLastModified(datasetPath));

      // a request without a parameter is a test to see if this is a valid cdremote endpoint.
      // just setHeader("Content-Description", "ncstream"), no body
      // on client, see DatasetUrl.disambiguateHttp
      if (req == null) {
          response.setContentType(ContentType.binary.getContentHeader());
          response.setHeader("Content-Description", "ncstream");
          return new ResponseEntity<>(null, responseHeaders, HttpStatus.OK);
        }

      switch (req.toLowerCase()) {
        case "form":    // ol
        case "cdl":
          ncfile.setLocation(datasetPath); // hide where the file is stored  LOOK
          String cdl = ncfile.toString();
          responseHeaders.set(ContentType.HEADER, ContentType.text.getContentHeader());
          return new ResponseEntity<>(cdl, responseHeaders, HttpStatus.OK);

        case "ncml":
          String ncml = ncfile.toNcML(absPath);
          responseHeaders.set(ContentType.HEADER, ContentType.xml.getContentHeader());
          return new ResponseEntity<>(ncml, responseHeaders, HttpStatus.OK);

        default:
          return new ResponseEntity<>("Unrecognized request", null, HttpStatus.BAD_REQUEST);
      }
    }
  }
everything but header, data, which is binary data, and capabilities which is XML