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 = bytesRead =
try: try:
await req.connection.reader.readUntil(addr buffer[0], await req.connection.reader.readUntil(addr buffer[0],
len(buffer), HeadersMark).wait( len(buffer), HeadersMark,
withLogs = true).wait(
req.session.headersTimeout) req.session.headersTimeout)
except AsyncTimeoutError: except AsyncTimeoutError:
raiseHttpReadError("Reading response headers timed out") raiseHttpReadError("Reading response headers timed out")

View File

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