Пример #1
0
    def get_content_type(self, allowed_content_types=None):
        """Determine content type of the request body.

        Does not do any body introspection, only checks header

        """
        if "Content-Type" not in self.headers:
            return None

        content_type = self.content_type
        allowed_content_types = (allowed_content_types or
                                 self.default_request_content_types)

        if content_type not in allowed_content_types:
            raise base_exception.InvalidContentType(content_type=content_type)
        return content_type
Пример #2
0
 def get_body_deserializer(self, content_type):
     try:
         return self.body_deserializers[content_type]
     except (KeyError, TypeError):
         raise base_exception.InvalidContentType(content_type=content_type)