Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
TheReverend403 committed Nov 12, 2024
1 parent 38675f8 commit cfbe88c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 49 deletions.
19 changes: 10 additions & 9 deletions cappuccino/urlinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import socket
import time
from copy import copy
from email.message import EmailMessage
from email.headerregistry import ContentDispositionHeader, ContentTypeHeader
from email.policy import EmailPolicy
from io import StringIO
from urllib.parse import urlparse

Expand Down Expand Up @@ -202,10 +203,10 @@ def _process_url(self, url: str): # noqa: C901

content_type = response.headers.get("Content-Type")
if content_type:
headers = EmailMessage()
headers["Content-Type"] = content_type
content_type = headers.get_content_type()
main_type = headers.get_content_maintype()
header: ContentTypeHeader = EmailPolicy.header_factory(
"content-type", content_type
)
main_type = header.maintype
if main_type not in self._allowed_content_types:
raise ContentTypeNotAllowedError(
f"{main_type} not in {self._allowed_content_types}"
Expand All @@ -215,10 +216,10 @@ def _process_url(self, url: str): # noqa: C901
size = int(response.headers.get("Content-Length", 0))
content_disposition = response.headers.get("Content-Disposition")
if content_disposition:
headers = EmailMessage()
headers["Content-Disposition"] = content_disposition
params = headers["Content-Disposition"].params
title = params.get("filename")
header: ContentDispositionHeader = EmailPolicy.header_factory(
"content-disposition", content_disposition
)
title = header.params.get("filename")
elif content_type in self._html_mimetypes or content_type == "text/plain":
content = self._stream_response(response)
if content and not size:
Expand Down
82 changes: 42 additions & 40 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cfbe88c

Please sign in to comment.