Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: log pending request content

NTFSvolume2b18d872e978
diff --git a/cyberdrop_dl/clients/http.py b/cyberdrop_dl/clients/http.py
index 6bc618e01..c241118ba 100644
--- a/cyberdrop_dl/clients/http.py
+++ b/cyberdrop_dl/clients/http.py
@@ -52,6 +52,9 @@ class _LazyResponseLog:
resp["content"] = truncated_preview(resp["content"])
return resp
+ def content(self) -> dict[str, Any]:
+ return {"content": self.__json__()["content"]}
+
def __str__(self) -> str:
return str(self.__json__())
@@ -256,6 +259,13 @@ class HTTPClient:
finally:
if self.request_done_callback:
self.request_done_callback(request.url, resp, exc)
+ if resp.has_content_not_logged:
+ logger.debug(
+ "Content from %s request [id=%s]\n%s",
+ request.method,
+ request.id,
+ _LazyResponseLog(resp).content(),
+ )
del exc
del resp
diff --git a/cyberdrop_dl/clients/response.py b/cyberdrop_dl/clients/response.py
index c8d345cb8..08a44560c 100644
--- a/cyberdrop_dl/clients/response.py
+++ b/cyberdrop_dl/clients/response.py
@@ -73,6 +73,7 @@ class AbstractResponse(ABC, Generic[_ResponseT]):
_text: str = EMPTY_CONTENT
_cache: dict[str, Any] = dataclasses.field(init=False, compare=False, default_factory=dict)
_lock: asyncio.Lock = dataclasses.field(init=False, compare=False, default_factory=asyncio.Lock)
+ _fully_serialized: bool = False
created_at: datetime.datetime = dataclasses.field(
init=False,
compare=False,
@@ -95,6 +96,11 @@ class AbstractResponse(ABC, Generic[_ResponseT]):
return self._text
+ @final
+ @property
+ def has_content_not_logged(self) -> bool:
+ return not self._fully_serialized and self._text is not EMPTY_CONTENT
+
def __json__(self) -> dict[str, Any]:
try:
content = self._get_content()
@@ -103,7 +109,9 @@ class AbstractResponse(ABC, Generic[_ResponseT]):
content = "<ERROR DECODING CONTENT>"
if content is EMPTY_CONTENT:
- content = "<DID NOT AWAIT FOR CONTENT>"
+ content = "<DID NOT AWAIT FOR CONTENT YET>"
+ else:
+ self._fully_serialized = True
return {
"url": str(self.url),