Contains functionality shared between the httpclient and asynchttpserver modules.
この API は不安定です。
型
HttpHeaders = ref object table*: TableRef[string, seq[string]]
- ソース 編集
HttpHeaderValues = distinct seq[string]
- ソース 編集
HttpCode = distinct range[0 .. 599]
- ソース 編集
HttpVersion = enum HttpVer11, HttpVer10
- ソース 編集
HttpMethod = enum HttpHead, ## Asks for the response identical to the one that would ## correspond to a GET request, but without the response ## body. HttpGet, ## Retrieves the specified resource. HttpPost, ## Submits data to be processed to the identified ## resource. The data is included in the body of the ## request. HttpPut, ## Uploads a representation of the specified resource. HttpDelete, ## Deletes the specified resource. HttpTrace, ## Echoes back the received request, so that a client ## can see what intermediate servers are adding or ## changing in the request. HttpOptions, ## Returns the HTTP methods that the server supports ## for specified address. HttpConnect, ## Converts the request connection to a transparent ## TCP/IP tunnel, usually used for proxies. HttpPatch ## Applies partial modifications to a resource.
- the requested HttpMethod Source Edit
定数
Http100 = 100
- ソース 編集
Http101 = 101
- ソース 編集
Http200 = 200
- ソース 編集
Http201 = 201
- ソース 編集
Http202 = 202
- ソース 編集
Http203 = 203
- ソース 編集
Http204 = 204
- ソース 編集
Http205 = 205
- ソース 編集
Http206 = 206
- ソース 編集
Http300 = 300
- ソース 編集
Http301 = 301
- ソース 編集
Http302 = 302
- ソース 編集
Http303 = 303
- ソース 編集
Http304 = 304
- ソース 編集
Http305 = 305
- ソース 編集
Http307 = 307
- ソース 編集
Http400 = 400
- ソース 編集
Http401 = 401
- ソース 編集
Http403 = 403
- ソース 編集
Http404 = 404
- ソース 編集
Http405 = 405
- ソース 編集
Http406 = 406
- ソース 編集
Http407 = 407
- ソース 編集
Http408 = 408
- ソース 編集
Http409 = 409
- ソース 編集
Http410 = 410
- ソース 編集
Http411 = 411
- ソース 編集
Http412 = 412
- ソース 編集
Http413 = 413
- ソース 編集
Http414 = 414
- ソース 編集
Http415 = 415
- ソース 編集
Http416 = 416
- ソース 編集
Http417 = 417
- ソース 編集
Http418 = 418
- ソース 編集
Http421 = 421
- ソース 編集
Http422 = 422
- ソース 編集
Http426 = 426
- ソース 編集
Http428 = 428
- ソース 編集
Http429 = 429
- ソース 編集
Http431 = 431
- ソース 編集
Http451 = 451
- ソース 編集
Http500 = 500
- ソース 編集
Http501 = 501
- ソース 編集
Http502 = 502
- ソース 編集
Http503 = 503
- ソース 編集
Http504 = 504
- ソース 編集
Http505 = 505
- ソース 編集
headerLimit = 10000
- ソース 編集
プロシージャ
proc newHttpHeaders(): HttpHeaders {...}{.raises: [], tags: [].}
- ソース 編集
proc newHttpHeaders(keyValuePairs: openArray[tuple[key: string, val: string]]): HttpHeaders {...}{. raises: [], tags: [].}
- ソース 編集
proc `$`(headers: HttpHeaders): string {...}{.raises: [], tags: [].}
- ソース 編集
proc clear(headers: HttpHeaders) {...}{.raises: [], tags: [].}
- ソース 編集
proc `[]`(headers: HttpHeaders; key: string): HttpHeaderValues {...}{.raises: [KeyError], tags: [].}
-
Returns the values associated with the given key. If the returned values are passed to a procedure expecting a string, the first value is automatically picked. If there are no values associated with the key, an exception is raised.
To access multiple values of a key, use the overloaded [] below or to get all of them access the table field directly.
ソース 編集 proc `[]`(headers: HttpHeaders; key: string; i: int): string {...}{.raises: [KeyError], tags: [].}
- 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. ソース 編集
proc `[]=`(headers: HttpHeaders; key, value: string) {...}{.raises: [], tags: [].}
- Sets the header entries associated with key to the specified value. Replaces any existing values. ソース 編集
proc `[]=`(headers: HttpHeaders; key: string; value: seq[string]) {...}{.raises: [], tags: [].}
- Sets the header entries associated with key to the specified list of values. Replaces any existing values. ソース 編集
proc add(headers: HttpHeaders; key, value: string) {...}{.raises: [KeyError], tags: [].}
- Adds the specified value to the specified key. Appends to any existing values associated with the key. ソース 編集
proc del(headers: HttpHeaders; key: string) {...}{.raises: [], tags: [].}
- Delete the header entries associated with key Source Edit
proc contains(values: HttpHeaderValues; value: string): bool {...}{.raises: [], tags: [].}
- Determines if value is one of the values inside values. Comparison is performed without case sensitivity. ソース 編集
proc hasKey(headers: HttpHeaders; key: string): bool {...}{.raises: [], tags: [].}
- ソース 編集
proc getOrDefault(headers: HttpHeaders; key: string; default = @[""].HttpHeaderValues): HttpHeaderValues {...}{. raises: [KeyError], tags: [].}
- Returns the values associated with the given key. If there are no values associated with the key, then default is returned. ソース 編集
proc len(headers: HttpHeaders): int {...}{.raises: [], tags: [].}
- ソース 編集
proc parseHeader(line: string): tuple[key: string, value: seq[string]] {...}{.raises: [], tags: [].}
-
Parses a single raw header HTTP line into key value pairs.
Used by asynchttpserver and httpclient internally and should not be used by you.
ソース 編集 proc `==`(protocol: tuple[orig: string, major, minor: int]; ver: HttpVersion): bool {...}{. raises: [], tags: [].}
- ソース 編集
proc contains(methods: set[HttpMethod]; x: string): bool {...}{.raises: [ValueError], tags: [].}
- ソース 編集
proc `$`(code: HttpCode): string {...}{.raises: [], tags: [].}
-
Converts the specified HttpCode into a HTTP status.
For example:
ソース 編集doAssert($Http404 == "404 Not Found")
proc `==`(a, b: HttpCode): bool {...}{.borrow.}
- ソース 編集
proc `==`(rawCode: string; code: HttpCode): bool {...}{.raises: [], tags: [].}
- ソース 編集
proc is2xx(code: HttpCode): bool {...}{.raises: [], tags: [].}
- Determines whether code is a 2xx HTTP status code. ソース 編集
proc is3xx(code: HttpCode): bool {...}{.raises: [], tags: [].}
- Determines whether code is a 3xx HTTP status code. ソース 編集
proc is4xx(code: HttpCode): bool {...}{.raises: [], tags: [].}
- Determines whether code is a 4xx HTTP status code. ソース 編集
proc is5xx(code: HttpCode): bool {...}{.raises: [], tags: [].}
- Determines whether code is a 5xx HTTP status code. ソース 編集
proc `$`(httpMethod: HttpMethod): string {...}{.raises: [], tags: [].}
- ソース 編集
イテレータ
iterator pairs(headers: HttpHeaders): tuple[key, value: string] {...}{.raises: [], tags: [].}
- Yields each key, value pair. ソース 編集
Converters
converter toString(values: HttpHeaderValues): string {...}{.raises: [], tags: [].}
- ソース 編集