Skip to content

Commit

Permalink
KTOR-8051 Revert EOFException change (#4627)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjhham authored Jan 30, 2025
1 parent 1c4f5b9 commit 55106bc
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,11 @@ public val ByteReadChannel.availableForRead: Int
*/
@OptIn(InternalAPI::class)
public suspend fun ByteReadChannel.readFully(out: ByteArray, start: Int = 0, end: Int = out.size) {
if (end > start && isClosedForRead) throw EOFException("Channel is already closed")
var offset = start
while (offset < end) {
if (readBuffer.exhausted()) awaitContent()
if (isClosedForRead) throw EOFException("Channel is already closed")

val count = min(end - offset, readBuffer.remaining.toInt())
readBuffer.readTo(out, offset, offset + count)
Expand Down

0 comments on commit 55106bc

Please sign in to comment.