Coverage for rest_framework/utils/mediatypes : 77%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Handling of media types, as found in HTTP Content-Type and Accept headers.
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7 """
""" Returns ``True`` if the media type in the first argument <= the media type in the second argument. The media types are strings as described by the HTTP spec.
Valid media type strings include:
'application/json; indent=4' 'application/json' 'text/*' '*/*' """
""" Returns a list of sets of media type strings, ordered by precedence. Precedence is determined by how specific a media type is:
3. 'type/subtype; param=val' 2. 'type/subtype' 1. 'type/*' 0. '*/*' """
media_type_str = ''
"""Return true if this MediaType satisfies the given MediaType.""" if key != 'q' and other.params.get(key, None) != self.params.get(key, None): return False
return False
def precedence(self): """ Return a precedence level from 0-3 for the media type given how specific it is. """ return 1
return unicode(self).encode('utf-8')
ret = "%s/%s" % (self.main_type, self.sub_type) for key, val in self.params.items(): ret += "; %s=%s" % (key, val) return ret |