summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/httpclient.nim8
-rw-r--r--lib/pure/unittest.nim18
2 files changed, 15 insertions, 11 deletions
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim
index a7e1aeab2..3afb625ee 100644
--- a/lib/pure/httpclient.nim
+++ b/lib/pure/httpclient.nim
@@ -156,7 +156,9 @@ proc parseChunks(s: Socket, timeout: int): string =
       else:
         httpError("Invalid chunk size: " & chunkSizeStr)
       inc(i)
-    if chunkSize <= 0: break
+    if chunkSize <= 0:
+      s.skip(2, timeout) # Skip \c\L
+      break
     result.setLen(ri+chunkSize)
     var bytesRead = 0
     while bytesRead != chunkSize:
@@ -521,7 +523,9 @@ proc parseChunks(client: AsyncHttpClient): Future[string] {.async.} =
       else:
         httpError("Invalid chunk size: " & chunkSizeStr)
       inc(i)
-    if chunkSize <= 0: break
+    if chunkSize <= 0:
+      discard await recvFull(client.socket, 2) # Skip \c\L
+      break
     result.add await recvFull(client.socket, chunkSize)
     discard await recvFull(client.socket, 2) # Skip \c\L
     # Trailer headers will only be sent if the request specifies that we want
diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim
index fa2e30ef4..6c0246f8b 100644
--- a/lib/pure/unittest.nim
+++ b/lib/pure/unittest.nim
@@ -35,7 +35,7 @@ var
   abortOnError* {.threadvar.}: bool
   outputLevel* {.threadvar.}: OutputLevel
   colorOutput* {.threadvar.}: bool
-  
+
   checkpoints {.threadvar.}: seq[string]
 
 checkpoints = @[]
@@ -61,23 +61,23 @@ proc testDone(name: string, s: TestStatus) =
     programResult += 1
 
   if outputLevel != PRINT_NONE and (outputLevel == PRINT_ALL or s == FAILED):
-    template rawPrint() = echo("[", $s, "] ", name, "\n")
+    template rawPrint() = echo("[", $s, "] ", name)
     when not defined(ECMAScript):
       if colorOutput and not defined(ECMAScript):
         var color = (if s == OK: fgGreen else: fgRed)
-        styledEcho styleBright, color, "[", $s, "] ", fgWhite, name, "\n"
+        styledEcho styleBright, color, "[", $s, "] ", fgWhite, name
       else:
         rawPrint()
     else:
       rawPrint()
-  
+
 template test*(name: expr, body: stmt): stmt {.immediate, dirty.} =
   bind shouldRun, checkpoints, testDone
 
   if shouldRun(name):
     checkpoints = @[]
     var testStatusIMPL {.inject.} = OK
-    
+
     try:
       testSetupIMPL()
       body
@@ -101,7 +101,7 @@ template fail* =
 
   when not defined(ECMAScript):
     if abortOnError: quit(1)
- 
+
   when declared(testStatusIMPL):
     testStatusIMPL = FAILED
   else:
@@ -111,7 +111,7 @@ template fail* =
 
 macro check*(conditions: stmt): stmt {.immediate.} =
   let checked = callsite()[1]
-  
+
   var
     argsAsgns = newNimNode(nnkStmtList)
     argsPrintOuts = newNimNode(nnkStmtList)
@@ -120,7 +120,7 @@ macro check*(conditions: stmt): stmt {.immediate.} =
   template asgn(a, value: expr): stmt =
     var a = value # XXX: we need "var: var" here in order to
                   # preserve the semantics of var params
-  
+
   template print(name, value: expr): stmt =
     when compiles(string($value)):
       checkpoint(name & " was " & $value)
@@ -146,7 +146,7 @@ macro check*(conditions: stmt): stmt {.immediate.} =
           checkpoint(lineInfoLit & ": Check failed: " & callLit)
           argPrintOuts
           fail()
-      
+
     var checkedStr = checked.toStrLit
     inspectArgs(checked)
     result = getAst(rewrite(checked, checked.lineinfo, checkedStr,