summary refs log tree commit diff stats
path: root/lib/pure/httpcore.nim
diff options
context:
space:
mode:
authorAndrea Ferretti <ferrettiandrea@gmail.com>2020-03-06 19:38:56 +0100
committerGitHub <noreply@github.com>2020-03-06 18:38:56 +0000
commit7ae081181831dcfe8ab83811f2b209c552c61fc7 (patch)
treedc28a8bbfbc8466988f11afa1cac8e9b9bd11991 /lib/pure/httpcore.nim
parent4bd388ad58ba246dce74aaa41b617b7cad0fff36 (diff)
downloadNim-7ae081181831dcfe8ab83811f2b209c552c61fc7.tar.gz
Fix #13573 and #13574 (#13575)
* Fix https://github.com/nim-lang/Nim/issues/13573 and https://github.com/nim-lang/Nim/issues/13574

* Restored asynchttpserver
Diffstat (limited to 'lib/pure/httpcore.nim')
-rw-r--r--lib/pure/httpcore.nim12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/pure/httpcore.nim b/lib/pure/httpcore.nim
index 1e9a85a57..e6e0d35c4 100644
--- a/lib/pure/httpcore.nim
+++ b/lib/pure/httpcore.nim
@@ -105,11 +105,15 @@ proc newHttpHeaders*(): HttpHeaders =
 
 proc newHttpHeaders*(keyValuePairs:
     openArray[tuple[key: string, val: string]]): HttpHeaders =
-  var pairs: seq[tuple[key: string, val: seq[string]]] = @[]
-  for pair in keyValuePairs:
-    pairs.add((pair.key.toLowerAscii(), @[pair.val]))
   new result
-  result.table = newTable[string, seq[string]](pairs)
+  result.table = newTable[string, seq[string]]()
+  for pair in keyValuePairs:
+    let key = pair.key.toLowerAscii()
+    if key in result.table:
+      result.table[key].add(pair.val)
+    else:
+      result.table[key] = @[pair.val]
+
 
 proc `$`*(headers: HttpHeaders): string =
   return $headers.table