diff options
author | flywind <43030857+xflywind@users.noreply.github.com> | 2020-11-06 18:40:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-06 11:40:14 +0100 |
commit | 218ff27b70c05340069d262204f785290467aa00 (patch) | |
tree | 34da1fd655b5b23245ec2cc9a1f2ac33a002a02b /lib/pure/httpcore.nim | |
parent | cdd459dd60e7cf69868ac23e754e8047df6afddc (diff) | |
download | Nim-218ff27b70c05340069d262204f785290467aa00.tar.gz |
fix #15851 (#15852)
* fix #15851 * {.cast(noSideEffect).}
Diffstat (limited to 'lib/pure/httpcore.nim')
-rw-r--r-- | lib/pure/httpcore.nim | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/pure/httpcore.nim b/lib/pure/httpcore.nim index d796c788d..b3d1da8d6 100644 --- a/lib/pure/httpcore.nim +++ b/lib/pure/httpcore.nim @@ -126,12 +126,14 @@ func newHttpHeaders*(keyValuePairs: new result result.table = newTable[string, seq[string]]() result.isTitleCase = titleCase + for pair in keyValuePairs: let key = result.toCaseInsensitive(pair.key) - if key in result.table: - result.table[key].add(pair.val) - else: - result.table[key] = @[pair.val] + {.cast(noSideEffect).}: + if key in result.table: + result.table[key].add(pair.val) + else: + result.table[key] = @[pair.val] func `$`*(headers: HttpHeaders): string {.inline.} = @@ -148,7 +150,8 @@ func `[]`*(headers: HttpHeaders, key: string): HttpHeaderValues = ## ## To access multiple values of a key, use the overloaded ``[]`` below or ## to get all of them access the ``table`` field directly. - return headers.table[headers.toCaseInsensitive(key)].HttpHeaderValues + {.cast(noSideEffect).}: + return headers.table[headers.toCaseInsensitive(key)].HttpHeaderValues converter toString*(values: HttpHeaderValues): string = return seq[string](values)[0] @@ -157,7 +160,8 @@ func `[]`*(headers: HttpHeaders, key: string, i: int): string = ## 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, ## an exception is raised. - return headers.table[headers.toCaseInsensitive(key)][i] + {.cast(noSideEffect).}: + return headers.table[headers.toCaseInsensitive(key)][i] proc `[]=`*(headers: HttpHeaders, key, value: string) = ## Sets the header entries associated with ``key`` to the specified value. |