is there any built in way to limit incoming reques...
# ktor
d
is there any built in way to limit incoming request content-length when receiving? I'm doing stuff like:
Copy code
val contentLength = call.request.header(HttpHeaders.ContentLength)?.toInt()
		// Before reading the body, check to see if they provided a content-length that is too large. (Note that
		// they could be using Transfer-Encoding:chunked and have no content-length.)
		if (contentLength != null && contentLength > config.maxContentLength) {
			throw RequestTooLargeException()
		}

		// Read the body into a "byte packet": a series of pool-allocated byte buffers. Note that we have
		// to explicit close (directly or via the inputStream) to recycle the buffers back into the pool.
		val body = call.receiveChannel().readRemaining(config.maxContentLength.toLong() + 1)
		if (body.remaining > config.maxContentLength) {
			body.close()
			throw RequestTooLargeException()
		}
		// Make an InputStream from the ByteReadPacket. Because we've already read all the bytes,
		// operations on this InputStream do not block.
		body.inputStream().use { rawStream ->
but maybe there's an easier way