code: public static ContentType get(
              final HttpEntity entity) throws ParseException, UnsupportedCharsetException {
          if (entity == null) {
              return null;
          }
          Header header = entity.getContentType();
          if (header != null) {
              HeaderElement[] elements = header.getElements();
              if (elements.length > 0) {
                  return create(elements[0]);
              }
          }
          return null;
      }
docs: Extracts <code>Content-Type</code> value from {@link HttpEntity} exactly as
  specified by the <code>Content-Type</code> header of the entity. Returns <code>null</code>
  if not specified.
  
  @param entity HTTP entity
  @return content type
  @throws ParseException if the given text does not represent a valid
  <code>Content-Type</code> value.