fix 'NoneType' and new ContentType supported. (#4818)

This commit is contained in:
Oliver Lee 2024-05-31 14:19:33 +08:00 • committed by GitHub
commit 176d91937d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -54,7 +54,7 @@ def get_url(url: str, user_agent: str = None) -> str:
if content_type:
main_content_type = response.headers.get('Content-Type').split(';')[0].strip()
else:
content_disposition = response.headers.get('Content-Disposition')
content_disposition = response.headers.get('Content-Disposition', '')
filename_match = re.search(r'filename="([^"]+)"', content_disposition)
if filename_match:
filename = unquote(filename_match.group(1))