Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(*): extend response content attribute #12

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mure/iterator.py
Original file line number Diff line number Diff line change
@@ -285,10 +285,11 @@ async def _asend_request(self, session: AsyncClient, request: Request) -> Respon
reason=response.reason_phrase,
ok=response.is_success,
text=text,
content=content,
url=str(response.url),
)
except Exception as error:
if self._log_errors:
LOGGER.error(error)

return Response(status=0, reason=repr(error), ok=False, text="", url="")
return Response(status=0, reason=repr(error), ok=False, text="", url="", content=b"")
5 changes: 4 additions & 1 deletion mure/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import json
from collections.abc import Mapping
from functools import cached_property
from hashlib import blake2b
from typing import Any, Literal, Mapping, NotRequired, TypedDict
from typing import Any, Literal, NotRequired, TypedDict

# supported http methods
Method = Literal["DELETE", "GET", "HEAD", "PATCH", "POST", "PUT"]
@@ -115,12 +116,14 @@ def __init__(
reason: str | None,
url: str,
text: str,
content: bytes,
):
self.ok = ok
self.status = status
self.reason = reason
self.url = url
self.text = text
self.content = content

def __repr__(self) -> str:
"""Return the string representation of the response."""