This commit is contained in:
Etan Kissling 2023-08-24 02:22:16 +02:00
parent d95c875361
commit 706e2a2db8
No known key found for this signature in database
GPG Key ID: B21DA824C5A3D03D
2 changed files with 5 additions and 2 deletions

View File

@ -519,7 +519,7 @@ proc readUntil*(rstream: AsyncStreamReader, pbytes: pointer, nbytes: int,
" <--> isNil(rstream.readerLoop) = " & $isNil(rstream.readerLoop)
if isNil(rstream.rsource):
try:
return await readUntil(rstream.tsource, pbytes, nbytes, sep)
return await readUntil(rstream.tsource, pbytes, nbytes, sep, withLogs = withLogs)
except CancelledError as exc:
raise exc
except TransportIncompleteError:

View File

@ -2412,7 +2412,7 @@ proc readOnce*(transp: StreamTransport, pbytes: pointer,
return count
proc readUntil*(transp: StreamTransport, pbytes: pointer, nbytes: int,
sep: seq[byte]): Future[int] {.async.} =
sep: seq[byte], withLogs = false): Future[int] {.async.} =
## Read data from the transport ``transp`` until separator ``sep`` is found.
##
## On success, the data and separator will be removed from the internal
@ -2459,6 +2459,9 @@ proc readUntil*(transp: StreamTransport, pbytes: pointer, nbytes: int,
else:
state = 0
if withLogs:
echo "readUntil: " & $transp.offset & " bytes available (" &
$index & ", " & $state & " == " & $len(sep) & ")"
(index, state == len(sep))
return k