MCPcopy Index your code
hub / github.com/clips/pattern / _parseHTTPContentType

Function _parseHTTPContentType

pattern/web/feed/feedparser.py:3617–3629  ·  view source on GitHub ↗

takes HTTP Content-Type header and returns (content type, charset) If no charset is specified, returns (content type, '') If no content type is specified, returns ('', '') Both return parameters are guaranteed to be lowercase strings

(content_type)

Source from the content-addressed store, hash-verified

3615 '''
3616
3617 def _parseHTTPContentType(content_type):
3618 '''takes HTTP Content-Type header and returns (content type, charset)
3619
3620 If no charset is specified, returns (content type, '')
3621 If no content type is specified, returns ('', '')
3622 Both return parameters are guaranteed to be lowercase strings
3623 '''
3624 content_type = content_type or ''
3625 content_type, params = cgi.parse_header(content_type)
3626 charset = params.get('charset', '').replace("'", "")
3627 if not isinstance(charset, unicode):
3628 charset = charset.decode('utf-8', 'ignore')
3629 return content_type, charset
3630
3631 sniffed_xml_encoding = u''
3632 xml_encoding = u''

Callers 1

_getCharacterEncodingFunction · 0.85

Calls 2

getMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…