* fix #15851

* {.cast(noSideEffect).}
This commit is contained in:
flywind 2020-11-06 18:40:14 +08:00 • committed by GitHub
commit 218ff27b70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View file

@ -126,8 +126,10 @@ func newHttpHeaders*(keyValuePairs:
new result new result
result.table = newTable[string, seq[string]]() result.table = newTable[string, seq[string]]()
result.isTitleCase = titleCase result.isTitleCase = titleCase
for pair in keyValuePairs: for pair in keyValuePairs:
let key = result.toCaseInsensitive(pair.key) let key = result.toCaseInsensitive(pair.key)
{.cast(noSideEffect).}:
if key in result.table: if key in result.table:
result.table[key].add(pair.val) result.table[key].add(pair.val)
else: else:
@ -148,6 +150,7 @@ func `[]`*(headers: HttpHeaders, key: string): HttpHeaderValues =
## ##
## To access multiple values of a key, use the overloaded ``[]`` below or ## To access multiple values of a key, use the overloaded ``[]`` below or
## to get all of them access the ``table`` field directly. ## to get all of them access the ``table`` field directly.
{.cast(noSideEffect).}:
return headers.table[headers.toCaseInsensitive(key)].HttpHeaderValues return headers.table[headers.toCaseInsensitive(key)].HttpHeaderValues
converter toString*(values: HttpHeaderValues): string = converter toString*(values: HttpHeaderValues): string =
@ -157,6 +160,7 @@ func `[]`*(headers: HttpHeaders, key: string, i: int): string =
## Returns the ``i``'th value associated with the given key. If there are ## Returns the ``i``'th value associated with the given key. If there are
## no values associated with the key or the ``i``'th value doesn't exist, ## no values associated with the key or the ``i``'th value doesn't exist,
## an exception is raised. ## an exception is raised.
{.cast(noSideEffect).}:
return headers.table[headers.toCaseInsensitive(key)][i] return headers.table[headers.toCaseInsensitive(key)][i]
proc `[]=`*(headers: HttpHeaders, key, value: string) = proc `[]=`*(headers: HttpHeaders, key, value: string) =

View file

@ -2,7 +2,7 @@ discard """
cmd: "nim c --experimental:strictFuncs --experimental:views $file" cmd: "nim c --experimental:strictFuncs --experimental:views $file"
""" """
import tables, streams, nre, parsecsv, uri import tables, streams, nre, parsecsv, uri, httpcore
type type
Contig2Reads = TableRef[string, seq[string]] Contig2Reads = TableRef[string, seq[string]]