private BoundWcsRequest negotiateFormat(BoundWcsRequest request) throws IOException {
    final Set<String> formats = request.getSupportedFormats();
    if (formats.isEmpty()) return request;
    if (!formats.contains(request.format)) {
      for (String format : Formats.preferredFormats) {
        if (formats.contains(format)) return request.withFormat(format);
      }

      // Note: If none of the preferred formats are offered by server
      // then we download a format and see if we can convert it to the
      // desired format
      return request.withFormat(formats.iterator().next());
    }
    return request;
  }