Types
HttpTableRef = ref HttpTable
- Source Edit
Procs
proc `$`(ht: HttpTables): string {....raises: [].}
- Returns string representation of HttpTable/Ref. Source Edit
proc add(ht: var HttpTables; key: string; value: SomeInteger) {....raises: [].}
- Add integer value to header with key key. Source Edit
proc add(ht: var HttpTables; key: string; value: string) {....raises: [].}
- Add string value to header with key key. Source Edit
proc clear(ht: var HttpTables) {....raises: [].}
- Resets the HtppTable so that it is empty. Source Edit
proc contains(ht: HttpTables; key: string): bool {....raises: [].}
- Returns true if header with name key is present in HttpTable/Ref. Source Edit
proc count(ht: HttpTables; key: string): int {....raises: [].}
- Returns number of headers with key key. Source Edit
proc getInt(ht: HttpTables; key: string): uint64 {....raises: [].}
-
Parse header with key key as unsigned integer.
Integers are parsed in safe way, there no exceptions or errors will be raised.
Procedure returns 0 value in next cases:
- The value is empty.
- Non-decimal character encountered during the parsing of the value.
- Result exceeds uint64 maximum allowed value.
proc getLastInt(ht: HttpTables; key: string): uint64 {....raises: [].}
-
Returns "last" value of header key as unsigned integer.
If there multiple headers with the same name key the value of last encountered header will be returned.
Unsigned integer will be parsed using rules of getInt() procedure.
Source Edit proc getLastString(ht: HttpTables; key: string): string {....raises: [].}
-
Returns "last" value of header key.
If there multiple headers with the same name key the value of last encountered header will be returned.
Source Edit proc getList(ht: HttpTables; key: string; default: openArray[string] = []): seq[ string] {....raises: [].}
- Returns sequence of headers with key key. Source Edit
proc getString(ht: HttpTables; key: string; default: string = ""): string {. ...raises: [].}
-
Returns concatenated value of headers with key key.
If there multiple headers with the same name key the result value will be concatenation using ,.
Source Edit proc hasKeyOrPut(ht: var HttpTables; key: string; value: string): bool {. ...raises: [].}
- Returns true if key is in the table ht, otherwise inserts value. Source Edit
proc init(htt: typedesc[HttpTable]): HttpTable {....raises: [].}
- Create empty HttpTable. Source Edit
proc init(htt: typedesc[HttpTable]; data: openArray[tuple[key: string, value: string]]): HttpTable {. ...raises: [].}
- Create HttpTable using array of tuples with header names and values. Source Edit
proc isEmpty(ht: HttpTables): bool {....raises: [].}
- Returns true if HttpTable ht is empty (do not have any values). Source Edit
proc new(htt: typedesc[HttpTableRef]): HttpTableRef {....raises: [].}
- Create empty HttpTableRef. Source Edit
proc new(htt: typedesc[HttpTableRef]; data: openArray[tuple[key: string, value: string]]): HttpTableRef {. ...raises: [].}
- Create HttpTableRef using array of tuples with header names and values. Source Edit
proc normalizeHeaderName(value: string): string {....raises: [], tags: [].}
-
Set any header name to have first capital letters in their name
For example: "content-length" become "<C>ontent-<L>ength" "expect" become "<E>xpect"
Source Edit proc set(ht: var HttpTables; key: string; value: string) {....raises: [].}
- Set/replace value of header with key key to value value. Source Edit
proc toList(ht: HttpTables; normKey = false): auto {....raises: [].}
- Returns sequence of (key, value) pairs. Source Edit
Iterators
iterator items(ht: HttpTables; normKey = false): tuple[key: string, value: seq[string]] {....raises: [].}
-
Iterate over HttpTable/Ref values.
If normKey is true, key name value will be normalized using normalizeHeaderName() procedure.
Source Edit iterator stringItems(ht: HttpTables; normKey = false): tuple[key: string, value: string] {....raises: [].}
-
Iterate over HttpTable/Ref values.
If normKey is true, key name value will be normalized using normalizeHeaderName() procedure.
Source Edit