animedex.render.raw

Four output renderers for RawResponse.

Per #3 §5.0:

The CLI in animedex.entry.cli picks one of these based on the mutually-exclusive output flags.

render_body

animedex.render.raw.render_body(envelope: RawResponse) str[source]

Default mode: print the response body as text.

Returns body_text when it decoded as UTF-8; otherwise base64- encodes body_bytes so the output is still printable. Callers that need the raw bytes for binary content should use the library API (animedex.api.call) instead of the CLI.

Parameters:

envelope (RawResponse) – The response envelope.

Returns:

Body text (or base64-encoded bytes when not decodable).

Return type:

str

render_include

animedex.render.raw.render_include(envelope: RawResponse) str[source]

-i mode: status line + response headers + blank + body.

Mirrors curl -i output. The header block uses the response’s own header casing as captured.

Parameters:

envelope (RawResponse) – The response envelope.

Returns:

Status + headers + body, separated by blank line.

Return type:

str

render_head

animedex.render.raw.render_head(envelope: RawResponse) str[source]

-I mode: status line + response headers, no body.

Parameters:

envelope (RawResponse) – The response envelope.

Returns:

Status + headers.

Return type:

str

render_debug

animedex.render.raw.render_debug(envelope: RawResponse, *, full_body: bool = False) str[source]

--debug mode: structured JSON envelope.

Emits the entire RawResponse as indented JSON. Body content is truncated to _DEBUG_BODY_CAP_BYTES (64 KiB) by default and tagged with body_truncated_at_bytes; pass full_body=True to emit the full body verbatim. Binary bodies that did not decode as UTF-8 are base64-encoded inside the JSON.

Credential headers in request.headers are already redacted by the dispatcher (see animedex.api._envelope.redact_headers()); this renderer does not perform additional redaction.

Parameters:
  • envelope (RawResponse) – The response envelope.

  • full_body (bool) – When True, do not truncate the body.

Returns:

Indented JSON of the envelope.

Return type:

str

selftest

animedex.render.raw.selftest() bool[source]

Smoke-test the four renderers.

Returns:

True on success.

Return type:

bool