readBodyBounded

fun Response.readBodyBounded(maxBytes: Long = DEFAULT_MAX_RESPONSE_BODY_BYTES): String?

Reads the response body as UTF-8 text, failing with IOException if it exceeds maxBytes rather than buffering an unbounded body. Returns null when the response has no body. The response is always closed.