mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-22 23:35:22 +00:00
Fix SIGSEGV in httpclient response body (#16766)
* initialize httpclient response bodyStream; prevent SIGSEGV when getBody is false * Update lib/pure/httpclient.nim * Update lib/pure/httpclient.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
This commit is contained in:
@@ -832,14 +832,16 @@ proc parseResponse(client: HttpClient | AsyncHttpClient,
|
||||
if not fullyRead:
|
||||
httpError("Connection was closed before full request has been made")
|
||||
|
||||
when client is HttpClient:
|
||||
result.bodyStream = newStringStream()
|
||||
else:
|
||||
result.bodyStream = newFutureStream[string]("parseResponse")
|
||||
|
||||
if getBody and result.code != Http204:
|
||||
client.bodyStream = result.bodyStream
|
||||
when client is HttpClient:
|
||||
client.bodyStream = newStringStream()
|
||||
result.bodyStream = client.bodyStream
|
||||
parseBody(client, result.headers, result.version)
|
||||
else:
|
||||
client.bodyStream = newFutureStream[string]("parseResponse")
|
||||
result.bodyStream = client.bodyStream
|
||||
assert(client.parseBodyFut.isNil or client.parseBodyFut.finished)
|
||||
# do not wait here for the body request to complete
|
||||
client.parseBodyFut = parseBody(client, result.headers, result.version)
|
||||
|
||||
Reference in New Issue
Block a user