Beispiel #1
0
    def get_content_type(self, allowed_content_types):
        """Determine content type of the request body."""
        if not "Content-Type" in self.headers:
            raise exception.InvalidContentType(content_type=None)

        content_type = self.content_type

        if content_type not in allowed_content_types:
            raise exception.InvalidContentType(content_type=content_type)
        else:
            return content_type
Beispiel #2
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 not "Content-Type" 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 exception.InvalidContentType(content_type=content_type)
        return content_type
Beispiel #3
0
 def get_body_deserializer(self, content_type):
     try:
         return self.body_deserializers[content_type]
     except (KeyError, TypeError):
         raise exception.InvalidContentType(content_type=content_type)