diff options
author | Andreas Rumpf <andreas@andreas-desktop> | 2010-02-02 21:20:22 +0100 |
---|---|---|
committer | Andreas Rumpf <andreas@andreas-desktop> | 2010-02-02 21:20:22 +0100 |
commit | bdcf1ec1f78b63fa4d04e1a4599f62cc7281ed38 (patch) | |
tree | 30b6c6b2ec72ee107e2570de5101fe5d2e8fba47 /lib/devel | |
parent | c7bd3f94cd6377f2a64ce67b59a4a31118bdabbb (diff) | |
download | Nim-bdcf1ec1f78b63fa4d04e1a4599f62cc7281ed38.tar.gz |
HTTP chunking should work now
Diffstat (limited to 'lib/devel')
-rwxr-xr-x | lib/devel/httpclient.nim | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/devel/httpclient.nim b/lib/devel/httpclient.nim index 83b7e8984..54f9321a1 100755 --- a/lib/devel/httpclient.nim +++ b/lib/devel/httpclient.nim @@ -68,7 +68,6 @@ proc parseChunks(d: var string, start: int, s: TSocket): string = while true: var chunkSize = 0 var digitFound = false - echo "number: ", copy(d, i, i + 10) while true: case d[i] of '0'..'9': @@ -85,12 +84,8 @@ proc parseChunks(d: var string, start: int, s: TSocket): string = i = -1 else: break inc(i) - - echo "chunksize: ", chunkSize - if chunkSize <= 0: - echo copy(d, i) - assert digitFound - break + if not digitFound: httpError("Chunksize expected") + if chunkSize <= 0: break while charAt(d, i, s) notin {'\C', '\L', '\0'}: inc(i) if charAt(d, i, s) == '\C': inc(i) if charAt(d, i, s) == '\L': inc(i) @@ -99,20 +94,19 @@ proc parseChunks(d: var string, start: int, s: TSocket): string = var x = copy(d, i, i+chunkSize-1) var size = x.len result.add(x) - + inc(i, size) if size < chunkSize: # read in the rest: var missing = chunkSize - size var L = result.len - setLen(result, L + missing) + setLen(result, L + missing) while missing > 0: var bytesRead = s.recv(addr(result[L]), missing) inc(L, bytesRead) dec(missing, bytesRead) - - # next chunk: - d = s.recv() - i = 0 + # next chunk: + d = s.recv() + i = 0 # skip trailing CR-LF: while charAt(d, i, s) in {'\C', '\L'}: inc(i) |