예제 #1
0
 def decode_content(self):
     '''Return the best possible representation of the response body.
     '''
     ct = self.headers.get('content-type')
     if ct:
         ct, options = parse_options_header(ct)
         charset = options.get('charset')
         if ct in JSON_CONTENT_TYPES:
             return self.json(charset)
         elif ct.startswith('text/'):
             return self.content_string(charset)
     return self.get_content()
예제 #2
0
 def decode_content(self):
     '''Return the best possible representation of the response body.
     '''
     ct = self.headers.get('content-type')
     if ct:
         ct, options = parse_options_header(ct)
         charset = options.get('charset')
         if ct in JSON_CONTENT_TYPES:
             return self.json(charset)
         elif ct.startswith('text/'):
             return self.content_string(charset)
     return self.get_content()
예제 #3
0
    def decode_content(self, object_hook=None):
        '''Return the best possible representation of the response body.

        :param object_hook: optional object hook function to pass to the
            ``json`` decoder if the content type is a ``json`` format.
        '''
        ct = self.headers.get('content-type')
        if ct:
            ct, options = parse_options_header(ct)
            charset = options.get('charset')
            if ct in JSON_CONTENT_TYPES:
                return self.json(charset, object_hook=object_hook)
            elif ct.startswith('text/'):
                return self.content_string(charset)
        return self.get_content()
예제 #4
0
 def content_type_options(self):
     content_type = self.environ.get('CONTENT_TYPE')
     if content_type:
         return parse_options_header(content_type)
     else:
         return None, {}
예제 #5
0
파일: wrappers.py 프로젝트: robgil/pulsar
 def content_type_options(self):
     content_type = self.environ.get('CONTENT_TYPE')
     if content_type:
         return parse_options_header(content_type)
     else:
         return None, {}