make httpclient work without zero terminators
This commit is contained in:
parent
22670aad84
commit
aeca422dbe
1 changed files with 3 additions and 7 deletions
|
|
@ -74,7 +74,7 @@
|
||||||
##
|
##
|
||||||
## .. code-block:: Nim
|
## .. code-block:: Nim
|
||||||
## import asyncdispatch, httpclient
|
## import asyncdispatch, httpclient
|
||||||
##
|
##
|
||||||
## proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} =
|
## proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} =
|
||||||
## echo("Downloaded ", progress, " of ", total)
|
## echo("Downloaded ", progress, " of ", total)
|
||||||
## echo("Current rate: ", speed div 1000, "kb/s")
|
## echo("Current rate: ", speed div 1000, "kb/s")
|
||||||
|
|
@ -247,7 +247,7 @@ proc parseChunks(s: Socket, timeout: int): string =
|
||||||
var i = 0
|
var i = 0
|
||||||
if chunkSizeStr == "":
|
if chunkSizeStr == "":
|
||||||
httpError("Server terminated connection prematurely")
|
httpError("Server terminated connection prematurely")
|
||||||
while true:
|
while i < chunkSizeStr.len:
|
||||||
case chunkSizeStr[i]
|
case chunkSizeStr[i]
|
||||||
of '0'..'9':
|
of '0'..'9':
|
||||||
chunkSize = chunkSize shl 4 or (ord(chunkSizeStr[i]) - ord('0'))
|
chunkSize = chunkSize shl 4 or (ord(chunkSizeStr[i]) - ord('0'))
|
||||||
|
|
@ -255,8 +255,6 @@ proc parseChunks(s: Socket, timeout: int): string =
|
||||||
chunkSize = chunkSize shl 4 or (ord(chunkSizeStr[i]) - ord('a') + 10)
|
chunkSize = chunkSize shl 4 or (ord(chunkSizeStr[i]) - ord('a') + 10)
|
||||||
of 'A'..'F':
|
of 'A'..'F':
|
||||||
chunkSize = chunkSize shl 4 or (ord(chunkSizeStr[i]) - ord('A') + 10)
|
chunkSize = chunkSize shl 4 or (ord(chunkSizeStr[i]) - ord('A') + 10)
|
||||||
of '\0':
|
|
||||||
break
|
|
||||||
of ';':
|
of ';':
|
||||||
# http://tools.ietf.org/html/rfc2616#section-3.6.1
|
# http://tools.ietf.org/html/rfc2616#section-3.6.1
|
||||||
# We don't care about chunk-extensions.
|
# We don't care about chunk-extensions.
|
||||||
|
|
@ -938,7 +936,7 @@ proc parseChunks(client: HttpClient | AsyncHttpClient): Future[void]
|
||||||
var i = 0
|
var i = 0
|
||||||
if chunkSizeStr == "":
|
if chunkSizeStr == "":
|
||||||
httpError("Server terminated connection prematurely")
|
httpError("Server terminated connection prematurely")
|
||||||
while true:
|
while i < chunkSizeStr.len:
|
||||||
case chunkSizeStr[i]
|
case chunkSizeStr[i]
|
||||||
of '0'..'9':
|
of '0'..'9':
|
||||||
chunkSize = chunkSize shl 4 or (ord(chunkSizeStr[i]) - ord('0'))
|
chunkSize = chunkSize shl 4 or (ord(chunkSizeStr[i]) - ord('0'))
|
||||||
|
|
@ -946,8 +944,6 @@ proc parseChunks(client: HttpClient | AsyncHttpClient): Future[void]
|
||||||
chunkSize = chunkSize shl 4 or (ord(chunkSizeStr[i]) - ord('a') + 10)
|
chunkSize = chunkSize shl 4 or (ord(chunkSizeStr[i]) - ord('a') + 10)
|
||||||
of 'A'..'F':
|
of 'A'..'F':
|
||||||
chunkSize = chunkSize shl 4 or (ord(chunkSizeStr[i]) - ord('A') + 10)
|
chunkSize = chunkSize shl 4 or (ord(chunkSizeStr[i]) - ord('A') + 10)
|
||||||
of '\0':
|
|
||||||
break
|
|
||||||
of ';':
|
of ';':
|
||||||
# http://tools.ietf.org/html/rfc2616#section-3.6.1
|
# http://tools.ietf.org/html/rfc2616#section-3.6.1
|
||||||
# We don't care about chunk-extensions.
|
# We don't care about chunk-extensions.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue