Closed
Description
In httpcore
, the constructor newHttpHeaders
does not accept repeated headers. httpcore
was recently refactored to add support for repeated headers - in particular we have types HttpHeaders
and HttpHeaderValues
, where before headers were just a stringTable
.
Still, the constructor newHttpHeaders
assumes that each header is passed a single time, as seen here:
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)
To check this behaviour it is enough to do
import httpcore, strutils
let h = newHttpHeaders({"a": "1", "a": "2"})
assert seq[string](h["a"]).join(",") == "1,2"