Returns the reponse MIME type for this view.

        :raises: :class:`pyramid.httpexceptions.HTTPNotAcceptable` if the
          MIME content type(s) the client specified can not be handled by
          the view.
340634
def _get_response_mime_type(self):
        
        view_name = self.request.view_name
        if view_name != '':
            mime_type = get_registered_mime_type_for_name(view_name)
        else:
            mime_type = None
            acc = None
            for acc in self.request.accept:
                if acc == '*/*':
                    # The client does not care; use the default.
                    mime_type = self.__get_default_response_mime_type()
                    break
                try:
                    mime_type = \
                            get_registered_mime_type_for_string(acc.lower())
                except KeyError:
                    pass
                else:
                    break
            if mime_type is None:
                if not acc is None:
                    # The client specified a MIME type we can not handle; this
                    # is a 406 exception. We supply allowed MIME content
                    # types in the body of the response.
                    headers = \
                        [('Location', self.request.path_url),
                         ('Content-Type', TextPlainMime.mime_type_string),
                         ]
                    mime_strings = get_registered_mime_strings()
                    exc = HTTPNotAcceptable('Requested MIME content type(s) '
                                            'not acceptable.',
                                            body=','.join(mime_strings),
                                            headers=headers)
                    raise exc
                mime_type = self.__get_default_response_mime_type()
        return mime_type
785912
def mime_type(self, path):
        """"""
        name, ext = os.path.splitext(path)
        return MIME_TYPES[ext]
531501
def supports_mime_type(self, mime_type):
        
        mime_type = ffi.new('char[]', mime_type.encode('utf8'))
        return bool(cairo.cairo_surface_supports_mime_type(
            self._pointer, mime_type))
487635
def get(self):
        
        content = {}
        if self.mime_type is not None:
            content["type"] = self.mime_type

        if self.content is not None:
            content["value"] = self.content
        return content
1180151
def validate_incoming_request
      unless request.media_type == Rack::Mime.mime_type('.json')
        error_msg = ServiceError.new(ServiceError::INVALID_CONTENT).to_hash
        logger.error("Validation failure: #{error_msg.inspect}, request media type: #{request.media_type} is not json")
        abort_request(error_msg)
      end
      unless auth_token && (auth_token == @token)
        error_msg = ServiceError.new(ServiceError::NOT_AUTHORIZED).to_hash
        logger.error("Validation failure: #{error_msg.inspect}, expected token: #{@token}, specified token: #{auth_token}")
        abort_request(error_msg)
      end
      unless @handle_fetched
        error_msg = ServiceError.new(ServiceError::SERVICE_UNAVAILABLE).to_hash
        logger.error("Validation failure: #{error_msg.inspect}, handles not fetched")
        abort_request(error_msg)
      end
    end
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();
    }
163961
def extract_mime(self, mime, def_mime='unk'):
        
        self['mime'] = def_mime
        if mime:
            self['mime'] = self.MIME_RE.split(mime, 1)[0]
            self['_content_type'] = mime
1120276
def mime_type(self):
        
        mime_type, encoding = mimetypes.guess_type(self.path)
        if not mime_type:
            mime_type = 'application/octet-stream'
        return mime_type
947787
def get(self, url, params=None, headers=None, content=None, form_content=None):
        # type: (str, Optional[Dict[str, str]], Optional[Dict[str, str]], Any, Optional[Dict[str, Any]]) -> ClientRequest
        
        request = self._request('GET', url, params, headers, content, form_content)
        request.method = 'GET'
        return request
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
1154519
def get_mimetype(self):
        
        template_name = self.get_template_names()[0]
        for extension, mimetype in turrentine_settings.TURRENTINE_MIMETYPE_EXTENSIONS:
            if template_name.endswith(extension):
                return mimetype
        return 'text/html'
435978
def get_mimetype(path):
        
        filename = os.path.split(path)[1]
        mimetype = mimetypes.guess_type(filename)[0]
        if mimetype is None:
            mimetype = 'text/x-plain'
        _logger().debug('mimetype detected: %s', mimetype)
        return mimetype
1218196
def _get_acceptable_response_type():
    """"""
    if ('Accept' not in request.headers or request.headers['Accept'] in
            ALL_CONTENT_TYPES):
        return JSON
    acceptable_content_types = set(
        request.headers['ACCEPT'].strip().split(','))
    if acceptable_content_types & HTML_CONTENT_TYPES:
        return HTML
    elif acceptable_content_types & JSON_CONTENT_TYPES:
        return JSON
    else:
        # HTTP 406 Not Acceptable
        raise InvalidAPIUsage(406)
384995
def select_renderer(self, request, renderers):
        
        if not len(request.accept_mimetypes):
            return renderers[0], renderers[0].mimetype

        for mimetype, quality in request.accept_mimetypes:
            accept_mimetype = MimeType.parse(mimetype)
            for renderer in renderers:
                if accept_mimetype.match(renderer.mimetype):
                    return renderer, renderer.mimetype.replace(params=accept_mimetype.params)

        return None, None
814561
def identify_request(request: RequestType):
    
    # Private encrypted JSON payload
    try:
        data = json.loads(decode_if_bytes(request.body))
        if "encrypted_magic_envelope" in data:
            return True
    except Exception:
        pass
    # Public XML payload
    try:
        xml = etree.fromstring(encode_if_text(request.body))
        if xml.tag == MAGIC_ENV_TAG:
            return True
    except Exception:
        pass
    return False
1354372
def _set_serializer_by_mime_type(self, mime_type):
        

        # ignore if binary response
        if isinstance(self._app_iter, BinaryResponse):
            self.logger.info("ignoring setting serializer for binary response")
            return

        for available_serializer in self._serializers:
            if available_serializer.content_type() == mime_type:
                self._selected_serializer = available_serializer
                self.logger.info("set serializer for mime type: %s" % mime_type)
                return

        self.logger.info("could not find serializer for mime type: %s" % mime_type)
        raise exception.UnsupportedVocabularyError(mime_type, self.supported_mime_types_str)
665771
def mime_type(instance):
    
    mime_pattern = re.compile(r'^(application|audio|font|image|message|model'
                              '|multipart|text|video)/[a-zA-Z0-9.+_-]+')
    for key, obj in instance['objects'].items():
        if ('type' in obj and obj['type'] == 'file' and 'mime_type' in obj):
            if enums.media_types():
                if obj['mime_type'] not in enums.media_types():
                    yield JSONError("The 'mime_type' property of object '%s' "
                                    "('%s') should be an IANA registered MIME "
                                    "Type of the form 'type/subtype'."
                                    % (key, obj['mime_type']), instance['id'],
                                    'mime-type')
            else:
                info("Can't reach IANA website; using regex for mime types.")
                if not mime_pattern.match(obj['mime_type']):
                    yield JSONError("The 'mime_type' property of object '%s' "
                                    "('%s') should be an IANA MIME Type of the"
                                    " form 'type/subtype'."
                                    % (key, obj['mime_type']), instance['id'],
                                    'mime-type')