client-api/src/main/java/com/streamsets/datacollector/client/ApiClient.java
private <T> T deserialize(Response response, TypeRef returnType) throws ApiException {
    String contentType = null;
    List<Object> contentTypes = response.getHeaders().get("Content-Type");
    if (contentTypes != null && !contentTypes.isEmpty()) {
      contentType = (String)contentTypes.get(0);
    }

    if (contentType == null) {
      throw new ApiException(500, "missing Content-Type in response");
    }

    if (contentType.startsWith("application/json")) {
      String body;
      if (response.hasEntity()) {
        body = response.readEntity(String.class);
      } else {
        body = "";
      }
      if (body.length() > 0) {
        return json.deserialize(body, returnType);
      }
      return null;
    } if (contentType.startsWith("image")) {
      return (T) response.readEntity(InputStream.class);
    } else {
      throw new ApiException(500, "can not deserialize Content-Type: " + contentType);
    }
  }
private <T> T deserialize(Response response, TypeRef returnType) throws ApiException {
    String contentType = null;
    List<Object> contentTypes = response.getHeaders().get("Content-Type");
    if (contentTypes != null && !contentTypes.isEmpty()) {
      contentType = (String)contentTypes.get(0);
    }

    if (contentType == null) {
      throw new ApiException(500, "missing Content-Type in response");
    }

    if (contentType.startsWith("application/json")) {
      String body;
      if (response.hasEntity()) {
        body = response.readEntity(String.class);
      } else {
        body = "";
      }
      if (body.length() > 0) {
        return json.deserialize(body, returnType);
      }
      return null;
    } if (contentType.startsWith("image")) {
      return (T) response.readEntity(InputStream.class);
    } else {
      throw new ApiException(500, "can not deserialize Content-Type: " + contentType);
    }
  }
Deserialize response body to Java object according to the Content-Type.