get Content-Type from URLConnection
516042
private String getRequestHeaderContentType() {
        String contentType = getRequestHeaderValue("Content-Type");
        if (contentType != null) {
            // remove parameter (Content-Type := type "/" subtype *[";" parameter] )
            int index = contentType.indexOf(';');
            if (index > 0)
                contentType = contentType.substring(0, index);
            contentType = contentType.trim();
        }
        return contentType;
    }
119674
private ContentType getContentType() {
        String contentTypeValue = m_request.getContentType();
        if (contentTypeValue == null) {
            return ContentType.TEXT_XML;
        }
        return new ContentType(contentTypeValue);
    }
176992
def content_type(self) -> str:
        """"""
        raw = self._headers.get(hdrs.CONTENT_TYPE)  # type: ignore
        if self._stored_content_type != raw:
            self._parse_content_type(raw)
        return self._content_type
928525
public static Element getContentElementByUrl(String url) throws Exception {
//        HttpRequest request = new HttpRequest(url);
        String html = okHttpRequester.getResponse(url).html();
        return getContentElementByHtml(html, url);
    }
877585
public Document readDocument(String url) {
        try {
            URL theURL = new URL(url);
            URLConnection conn = connectWithRedirect(theURL);
            if (conn == null)
                return null;

            ProvFormat format = null;
            String content_type = conn.getContentType();

            logger.debug("Content-type: " + content_type);
            if (content_type != null) {
                // Need to trim optional parameters
                // Content-Type: text/plain; charset=UTF-8
                int end = content_type.indexOf(";");
                if (end < 0) {
                    end = content_type.length();
                }
                String actual_content_type = content_type.substring(0, end)
                        .trim();
                logger.debug("Found Content-type: " + actual_content_type);
                // TODO: might be worth skipping if text/plain as that seems
                // to be the
                // default returned by unconfigured web servers
                format = mimeTypeRevMap.get(actual_content_type);
            }
            logger.debug("Format after Content-type: " + format);

            if (format == null) {
                format = getTypeForFile(theURL.toString());
            }
            logger.debug("Format after extension: " + format);

            InputStream content_stream = conn.getInputStream();

            return readDocument(content_stream, format,url);
        } catch (IOException e) {
            throw new InteropException(e);
        }
    }
295399
private static String getContentType(String fileExtension) {
        if (fileExtension == null) {
            return null;
        }
                
        String contentType = null;
        
        fileExtension = fileExtension.toLowerCase();

        if ("html".equals(fileExtension)) {
            contentType = "text/html";
        }
        else if ("htm".equals(fileExtension)) {
            contentType = "text/html";
        }
        else if ("jar".equals(fileExtension)) {
            contentType = "application/java-archive";
        }
        else if ("js".equals(fileExtension)) {
            contentType = "text/javascript";
        }
        else if ("png".equals(fileExtension)) {
            contentType = "image/png";
        }
        else if ("gif".equals(fileExtension)) {
            contentType = "image/gif";
        }
        else if ("jpg".equals(fileExtension)) {
            contentType = "image/jpeg";
        }
        else if ("jpeg".equals(fileExtension)) {
            contentType = "image/jpeg";
        }
        else if ("css".equals(fileExtension)) {
            contentType = "text/css";
        }
        else if ("swf".equals(fileExtension)) {
            contentType = "application/x-shockwave-flash";
        }
        else if ("xap".equals(fileExtension)) {
            contentType = "application/x-silverlight-app";
        }
        else if ("htc".equals(fileExtension)) {
            contentType = "text/x-component";
        }
        else if ("jnlp".equals(fileExtension)) {
            contentType = "application/x-java-jnlp-file";
        }
        else if ("manifest".equals(fileExtension)) {
            contentType = "text/cache-manifest";
        }
        else if ("appcache".equals(fileExtension)) {
            contentType = "text/cache-manifest";
        }
        else if ("vtt".equals(fileExtension)) {
            contentType = "text/vtt";
        }
        else if ("aspx".equals(fileExtension)) {
            contentType = "text/html";
        }
        else if ("apk".equals(fileExtension)) {
            contentType = "application/vnd.android.package-archive";
        }

        return contentType;
    }
44200
def get_content_type(*names):
    """"""
    for name in names:
        if name is not None:
            mimetype, encoding = mimetypes.guess_type(name)
            if mimetype is not None:
                if isinstance(mimetype, bytes):
                    return mimetype.decode("ascii")
                else:
                    return mimetype
    else:
        return "application/octet-stream"
1228112
public String getContentType() {
		ContentTypeHeader cth = (ContentTypeHeader) this.message
				.getHeader(getCorrectHeaderName(ContentTypeHeader.NAME));
		if (cth != null) {
			// Fix For Issue http://code.google.com/p/mobicents/issues/detail?id=2659
			// getContentType doesn't return the full header value
//			String contentType = cth.getContentType();
//			String contentSubType = cth.getContentSubType();
//			if(contentSubType != null)
//				return contentType + "/" + contentSubType;
			return ((HeaderExt)cth).getValue();
		}
		return null;
	}
341628
static String parseContentType(String contentType) throws IOException {
        if (contentType.indexOf(System.getProperty("line.separator")) > 0) {
            BufferedReader reader = new BufferedReader(new StringReader(contentType));

            try {
                String plainContentType = reader.readLine();
                if (plainContentType != null && plainContentType.trim().endsWith(";")) {
                    plainContentType = plainContentType.trim().substring(0, plainContentType.length() - 1);
                }

                return plainContentType;
            } finally {
                try {
                    reader.close();
                } catch (IOException e) {
                    log.warn("Failed to close reader", e);
                }
            }
        }

        return contentType;
    }
817722
def get_content_type(self, content_type):
        
        qs = self.get_queryset()
        return qs.filter(content_type__name=content_type)
526667
def _parse_content_type(self, value):
        
        content_type, params = parse_header(value)
        if 'charset' in params:
            charset = params['charset']
        else:
            charset = None
        return content_type, charset
1062539
def _GetURLContent(url):
    """"""
    response = urllib_request.urlopen(url)
    encoding = response.info().get('Content-Encoding')
    if encoding == 'gzip':
        content = _Gunzip(response.read())
    else:
        content = response.read()
    return content
331409
private MediaType findContentType(final String url) {
        if (url == null) {
            return null;
        }

        if (url.startsWith("file")) {
            return APPLICATION_OCTET_STREAM_TYPE;
        } else if (url.startsWith("http")) {
            try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
                final HttpHead httpHead = new HttpHead(url);
                try (CloseableHttpResponse response = httpClient.execute(httpHead)) {
                    if (response.getStatusLine().getStatusCode() == SC_OK) {
                        final Header contentType = response.getFirstHeader(CONTENT_TYPE);
                        if (contentType != null) {
                            return MediaType.valueOf(contentType.getValue());
                        }
                    }
                }
            } catch (final IOException e) {
                LOGGER.warn("Unable to retrieve external content from {} due to {}", url, e.getMessage());
            } catch (final Exception e) {
                throw new RepositoryRuntimeException(e);
            }
        }
        LOGGER.debug("Defaulting to octet stream for media type");
        return APPLICATION_OCTET_STREAM_TYPE;
    }
553031
@Override
    public String getContentType() {
        try {
            collaborator.preInvoke(componentMetaData);
            return request.getContentType();
        } finally {
            collaborator.postInvoke();
        }
    }
774576
def _get_name_from_content_type(self, request):
        

        content_type = request.META.get('CONTENT_TYPE', None)
        if content_type:
            # remove the possible charset-encoding info
            return util.strip_charset(content_type)
        return None
766532
@Override
   public String getContentEncoding()
   {
      try
      {
         if (!connected)
         {
            connect();
         }

         return nodeRepresentation.getContentEncoding();
      }
      catch (Exception e)
      {
         if (LOG.isTraceEnabled())
         {
            LOG.trace("An exception occurred: " + e.getMessage());
         }
      }
      return null;
   }
375443
def content_type(self) -> ContentType:
        """"""
        if self._ctype:
            return self._ctype
        return (ContentType.config if self.parent.config else
                ContentType.nonconfig)