Bytes with their content type and length (Effect's Uint8Array
body). text is the text they were encoded from, if any.
Attributes#
| Attribute | Type | Description |
|---|---|---|
body | bytes | |
content_type | str | |
content_length | int | |
text | str | None = None | |
tag | Literal['Bytes'] = 'Bytes' |
Functions#
__init__#
__init__(body, content_type, content_length, text=None) -> None| Parameter | Type | Description |
|---|---|---|
body | bytes | |
content_type | str | |
content_length | int | |
text | str | None = None |
to_json#
to_json() -> dict[str, object]Returns dict[str, object]
def to_json(self) -> dict[str, object]:
readable = self.content_type.startswith("text/") or self.content_type.endswith("json")
return {
"_id": "effect/HttpBody",
"_tag": "Bytes",
"body": self.body.decode("utf-8", "replace")
if readable
else f"bytes({len(self.body)})",
"content_type": self.content_type,
"content_length": self.content_length,
}