Fix issue #10726 - HTTP response without Content-Length is not accessible (#11904)

* Add patch by @xenogenesi

* Async test for HTTP/1.1 without Content-Length

* Apply suggestions from code review

Co-Authored-By: Dominik Picheta <dominikpicheta@googlemail.com>
This commit is contained in:
konradmb 2019-08-08 08:41:56 +02:00 • committed by Andreas Rumpf
commit addd7b5e20
2 changed files with 48 additions and 30 deletions

View file

@ -340,7 +340,10 @@ proc parseBody(s: Socket, headers: HttpHeaders, httpVersion: string, timeout: in
# -REGION- Connection: Close
# (http://tools.ietf.org/html/rfc2616#section-4.4) NR.5
if headers.getOrDefault"Connection" == "close" or httpVersion == "1.0":
let implicitConnectionClose =
httpVersion == "1.0" or
httpVersion == "1.1" # This doesn't match the HTTP spec, but it fixes issues for non-conforming servers.
if headers.getOrDefault"Connection" == "close" or implicitConnectionClose:
var buf = ""
while true:
buf = newString(4000)
@ -811,7 +814,10 @@ proc parseBody(client: HttpClient | AsyncHttpClient,
# -REGION- Connection: Close
# (http://tools.ietf.org/html/rfc2616#section-4.4) NR.5
if headers.getOrDefault"Connection" == "close" or httpVersion == "1.0":
let implicitConnectionClose =
httpVersion == "1.0" or
httpVersion == "1.1" # This doesn't match the HTTP spec, but it fixes issues for non-conforming servers.
if headers.getOrDefault"Connection" == "close" or implicitConnectionClose:
while true:
let recvLen = await client.recvFull(4000, client.timeout, true)
if recvLen != 4000: