Returns the ``Content-Type`` header to be used for this request.
497724
def get_content_type(self):
        
        mime_type, encoding = mimetypes.guess_type(self.filepath)
        if encoding == "gzip":
            return "application/gzip"
        elif encoding is not None:
            return "application/octet-stream"
        elif mime_type is not None:
            return mime_type
        # if mime_type not detected, use application/octet-stream
        else:
            return "application/octet-stream"
496419
def get_content_type(self) -> str:
        
        assert self.absolute_path is not None
        mime_type, encoding = mimetypes.guess_type(self.absolute_path)
        # per RFC 6713, use the appropriate type for a gzip compressed file
        if encoding == "gzip":
            return "application/gzip"
        # As of 2015-07-21 there is no bzip2 encoding defined at
        # http://www.iana.org/assignments/media-types/media-types.xhtml
        # So for that (and any other encoding), use octet-stream.
        elif encoding is not None:
            return "application/octet-stream"
        elif mime_type is not None:
            return mime_type
        # if mime_type not detected, use application/octet-stream
        else:
            return "application/octet-stream"
1267653
public MediaType getContentType() {
        if (isNull(this.contentType)) {
            contentType = getHeader(HeaderName.CONTENT_TYPE)
                .map(MediaType::of)
                .orElse(WILDCARD);
        }

        return contentType;
    }
983260
def get_response_content_type(self):
        """"""
        if self._best_response_match is None:
            settings = get_settings(self.application, force_instance=True)
            acceptable = headers.parse_accept(
                self.request.headers.get(
                    'Accept',
                    settings.default_content_type
                    if settings.default_content_type else '*/*'))
            try:
                selected, _ = algorithms.select_content_type(
                    acceptable, settings.available_content_types)
                self._best_response_match = '/'.join(
                    [selected.content_type, selected.content_subtype])
                if selected.content_suffix is not None:
                    self._best_response_match = '+'.join(
                        [self._best_response_match, selected.content_suffix])
            except errors.NoMatch:
                self._best_response_match = settings.default_content_type

        return self._best_response_match
277635
def _mainType(self, resp):
        
        if self.PY2:
            return resp.headers.maintype
        elif self.PY3:
            return resp.headers.get_content_maintype()
        else:
            return None
534450
private function setHeaderContentType()
    {
        $fileName = basename( $this->fileName );
        if ( $this->contentDisposition !== null && $this->contentDisposition->fileName !== null )
        {
            $fileName = $this->contentDisposition->fileName;
        }

        $this->setHeader( 'Content-Type',
                          $this->contentType . '/' . $this->mimeType . '; ' . 'name="' . $fileName . '"' );
    }
464631
def content_type(self):
        
        type_formencoded = "application/x-www-form-urlencoded"

        ctype = self.request.META.get('CONTENT_TYPE', type_formencoded)

        if type_formencoded in ctype:
            return None

        return ctype
599215
def content_type(self, mime_type: Optional[MimeType] = None) -> str:
        
        fmt = self.__file.mime_type(type_=mime_type)
        return 'Content-Type: {}'.format(fmt)
695102
private String contentType(ResponseWrapper responseWrapper) {
        return StringUtil.isEmpty(responseWrapper.getHttpContentType()) ? Config.getContentType() : responseWrapper.getHttpContentType();
    }
952960
def get_content_type(self):
        
        extension = self.path_params.get('_extension')
        for ext, mime in self.EXTENSION_MAP:
            if ext == extension:
                return mime
        # Else: use the Accept headers
        if self.response.vary is None:
            self.response.vary = ['Accept']
        else:
            self.response.vary.append('Accept')
        types = [mime for ext, mime in self.EXTENSION_MAP]
        ct = self.request.accept.best_match(types)
        # No best match found. The specification allows us to either return a
        # 406 or just use another format in this case.
        # We pick the default format, though that may become a configurable
        # behavior in the future.
        if not ct:
            ct = types[0]
        return ct
723387
public function getContentType()
    {
        $contentType = $this->headers->first('Content-Type');
        if (($pos = strpos($contentType, ';')) !== false) {
            $contentType = substr($contentType, 0, $pos);
        }

        return $contentType;
    }
715898
private ContentType getAcceptType() {
        // If the format header is present, it overrides the ACCEPT header.
        String format = m_variableMap.get("format");
        if (format != null) {
            return new ContentType(format);
        }
        String acceptParts = m_request.getHeader(HttpDefs.ACCEPT);
        if (!Utils.isEmpty(acceptParts)) {
	        for (String acceptPart : acceptParts.split(",")) {
	            ContentType acceptType = new ContentType(acceptPart);
	            if (acceptType.isJSON() || acceptType.isXML() || acceptType.isPlainText()) {
	                return acceptType;
	            }
	        }
        }
        return getContentType();
    }
801869
public static function getContentType() {
    if(null === self::$contentType) {
      self::$contentType = @trim($_SERVER['HTTP_CONTENT_TYPE']);
      if(!self::$contentType) {
        self::$contentType = @trim($_SERVER['CONTENT_TYPE']);
        if(!self::$contentType) {
          self::$contentType = false;
        }
      }
    }
    return self::$contentType;
  }
75925
def content_type(self):
        """"""

        if hasattr(self, '_content_type'):
            return self._content_type

        filename, extension = os.path.splitext(self._file_path)
        if extension == '.csv':
            self._content_type = 'text/csv'
        elif extension == '.tsv':
            self._content_type = 'text/tab-separated-values'
        else:
            self._content_type = 'text/plain'

        return self._content_type
655902
def _parse_content_type_header(header):
    

    tokens = header.split(';')
    content_type, params = tokens[0].strip(), tokens[1:]
    params_dict = {}
    items_to_strip = "\"' "

    for param in params:
        param = param.strip()
        if param:
            key, value = param, True
            index_of_equals = param.find("=")
            if index_of_equals != -1:
                key = param[:index_of_equals].strip(items_to_strip)
                value = param[index_of_equals + 1:].strip(items_to_strip)
            params_dict[key.lower()] = value
    return content_type, params_dict
1049033
private String getContentType(HttpServletRequest pRequest) {
        if (responseMessageTypes != null) {
            String accept = pRequest.getHeader("Accept");

            for (String type : responseMessageTypes) {
                // Note: This is not 100% correct way of doing content negotiation
                // But we just want a compatible result, quick, so this is okay
                if (StringUtil.contains(accept, type)) {
                    return type;
                }
            }
        }

        // If none found, return default
        return DEFAULT_TYPE;
    }
1235382
def _get_headers(environ):
    # type: (Dict[str, str]) -> Iterator[Tuple[str, str]]
    
    for key, value in environ.items():
        key = str(key)
        if key.startswith("HTTP_") and key not in (
            "HTTP_CONTENT_TYPE",
            "HTTP_CONTENT_LENGTH",
        ):
            yield key[5:].replace("_", "-").title(), value
        elif key in ("CONTENT_TYPE", "CONTENT_LENGTH"):
            yield key.replace("_", "-").title(), value