This commit is contained in:
Etan Kissling 2023-08-24 00:59:30 +02:00
parent 0035f4fa66
commit d95c875361
No known key found for this signature in database
GPG Key ID: B21DA824C5A3D03D
2 changed files with 6 additions and 2 deletions

View File

@ -970,7 +970,8 @@ proc getResponse(req: HttpClientRequestRef): Future[HttpClientResponseRef] {.
bytesRead =
try:
await req.connection.reader.readUntil(addr buffer[0],
len(buffer), HeadersMark).wait(
len(buffer), HeadersMark,
withLogs = true).wait(
req.session.headersTimeout)
except AsyncTimeoutError:
raiseHttpReadError("Reading response headers timed out")

View File

@ -492,7 +492,7 @@ proc readOnce*(rstream: AsyncStreamReader, pbytes: pointer,
return count
proc readUntil*(rstream: AsyncStreamReader, pbytes: pointer, nbytes: int,
sep: seq[byte]): Future[int] {.async.} =
sep: seq[byte], withLogs = false): Future[int] {.async.} =
## Read data from the read-only stream ``rstream`` until separator ``sep`` is
## found.
##
@ -514,6 +514,9 @@ proc readUntil*(rstream: AsyncStreamReader, pbytes: pointer, nbytes: int,
if nbytes == 0:
raise newAsyncStreamLimitError()
if withLogs:
echo "isNil(rstream.rsource) = " & $isNil(rstream.rsource) &
" <--> isNil(rstream.readerLoop) = " & $isNil(rstream.readerLoop)
if isNil(rstream.rsource):
try:
return await readUntil(rstream.tsource, pbytes, nbytes, sep)