def _guess_mime_type(headers: CaseInsensitiveDict) -> Optional[str]:
location = headers.get('location')
if location:
mime_type, _ = mimetypes.guess_type(location)
if mime_type:
return mime_type
# Parse mime type from content-type header, e.g. 'image/jpeg;charset=US-ASCII' -> 'image/jpeg'
mime_type, _ = cgi.parse_header(headers.get('content-type', ''))
return mime_type or None
评论列表
文章目录