Types
ContentEncodingFlags {.pure.} = enum Identity, Br, Compress, Deflate, Gzip
- Source Edit
HttpAddressError = object of HttpTransportError
- Source Edit
HttpAddressErrorType {.pure.} = enum InvalidUrlScheme = "Unsupported URL scheme", InvalidPortNumber = "Invalid port number", MissingHostname = "Hostname missing from URL", InvalidIpHostname = "Invalid IP", NameLookupFailed = "DNS lookup failed", NoAddressResolved = "Hostname has no addresses"
- Source Edit
HttpConnectionError = object of HttpTransportError
- Source Edit
HttpCriticalError {....deprecated.} = object of HttpProtocolError
- Source Edit
HttpDisconnectError = object of HttpReadError
- Source Edit
HttpError = object of AsyncError
- Source Edit
HttpInterruptError = object of HttpError
- Source Edit
HttpInvalidUsageError = object of HttpError
- Source Edit
HttpMessage = object code*: HttpCode contentType*: MediaType message*: string
- Source Edit
HttpProtocolError = object of HttpError code*: HttpCode
- Source Edit
HttpReadError = object of HttpTransportError
- Source Edit
HttpReadLimitError = object of HttpReadError
- Source Edit
HttpRecoverableError {....deprecated.} = object of HttpProtocolError
- Source Edit
HttpRedirectError = object of HttpTransportError
- Source Edit
HttpRequestBodyError = object of HttpRequestError
- Source Edit
HttpRequestBodyTooLargeError = object of HttpRequestBodyError
- Source Edit
HttpRequestError = object of HttpProtocolError
- Source Edit
HttpRequestHeadersError = object of HttpRequestError
- Source Edit
HttpResponseError = object of HttpProtocolError
- Source Edit
HttpResult[T] = Result[T, string]
- Source Edit
HttpResultCode[T] = Result[T, HttpCode]
- Source Edit
HttpResultMessage[T] = Result[T, HttpMessage]
- Source Edit
HttpTransportError = object of HttpError
- Source Edit
HttpUseClosedError = object of HttpInvalidUsageError
- Source Edit
HttpWriteError = object of HttpTransportError
- Source Edit
KeyValueTuple = tuple[key: string, value: string]
- Source Edit
QueryParamsFlag {.pure.} = enum CommaSeparatedArray ## Enable usage of comma symbol as separator of array ## items
- Source Edit
TransferEncodingFlags {.pure.} = enum Identity, Chunked, Compress, Deflate, Gzip
- Source Edit
Consts
AcceptHeaderName = "accept"
- Source Edit
AuthorizationHeader = "authorization"
- Source Edit
ConnectionHeader = "connection"
- Source Edit
ContentDispositionHeader = "content-disposition"
- Source Edit
ContentEncodingHeader = "content-encoding"
- Source Edit
ContentLengthHeader = "content-length"
- Source Edit
ContentTypeHeader = "content-type"
- Source Edit
CriticalHttpAddressError = {HttpAddressErrorType.InvalidUrlScheme, HttpAddressErrorType.InvalidPortNumber, HttpAddressErrorType.MissingHostname, HttpAddressErrorType.InvalidIpHostname}
- Source Edit
DateHeader = "date"
- Source Edit
ExpectHeader = "expect"
- Source Edit
HeadersMark = [0x0D'u8, 0x0A'u8, 0x0D'u8, 0x0A'u8]
- Source Edit
HostHeader = "host"
- Source Edit
HttpServerRequestTrackerName = "httpserver.request"
- Source Edit
HttpServerResponseTrackerName = "httpserver.response"
- Source Edit
HttpServerSecureConnectionTrackerName = "httpserver.secure.connection"
- Source Edit
HttpServerUnsecureConnectionTrackerName = "httpserver.unsecure.connection"
- Source Edit
LocationHeader = "location"
- Source Edit
MaximumBodySizeError = "Maximum size of request\'s body reached"
- Source Edit
MultipartContentType = (media: "multipart", subtype: "form-data")
- Source Edit
PostMethods = {MethodPost, MethodPatch, MethodPut, MethodDelete}
- Source Edit
ProxyAuthorizationHeader = "proxy-authorization"
- Source Edit
RecoverableHttpAddressError = {HttpAddressErrorType.NameLookupFailed, HttpAddressErrorType.NoAddressResolved}
- Source Edit
ServerHeader = "server"
- Source Edit
TransferEncodingHeader = "transfer-encoding"
- Source Edit
UrlEncodedContentType = (media: "application", subtype: "x-www-form-urlencoded")
- Source Edit
UserAgentHeader = "user-agent"
- Source Edit
Procs
func bytesToString(src: openArray[byte]): string {....raises: [], tags: [].}
-
Convert array of bytes to a string.
Note, that this procedure assume that sizeof(byte) == sizeof(char) == 1. If this equation is not correct this procedures MUST not be used.
Source Edit proc bytesToString(src: openArray[byte]; dst: var openArray[char]) {....raises: [], tags: [].}
-
Convert array of bytes to array of characters.
Note, that this procedure assume that sizeof(byte) == sizeof(char) == 1. If this equation is not correct this procedures MUST not be used.
Source Edit func encodeBasicAuth(username, password: string): string {....raises: [], tags: [].}
- Source Edit
func getContentEncoding(ch: openArray[string]): HttpResult[ set[ContentEncodingFlags]] {....raises: [], tags: [].}
- Parse value of multiple HTTP headers Content-Encoding and return it as set of ContentEncodingFlags. Source Edit
func getContentType(ch: openArray[string]): HttpResult[ContentTypeData] {. ...raises: [], tags: [].}
- Check and prepare value of Content-Type header. Source Edit
func getTransferEncoding(ch: openArray[string]): HttpResult[ set[TransferEncodingFlags]] {....raises: [], tags: [].}
- Parse value of multiple HTTP headers Transfer-Encoding and return it as set of TransferEncodingFlags. Source Edit
func init(t: typedesc[HttpMessage]; code: HttpCode): HttpMessage {....raises: [].}
- Source Edit
func init(t: typedesc[HttpMessage]; code: HttpCode; message: string): HttpMessage {. ...raises: [].}
- Source Edit
func init(t: typedesc[HttpMessage]; code: HttpCode; message: string; contentType: MediaType): HttpMessage {....raises: [].}
- Source Edit
func init(t: typedesc[HttpMessage]; code: HttpCode; message: string; contentType: string): HttpMessage {....raises: [].}
- Source Edit
func isCriticalError(error: HttpAddressErrorType): bool {....raises: [], tags: [].}
- Source Edit
func isPersistent(version: HttpVersion; headers: HttpTable): bool {....raises: [], tags: [].}
- Source Edit
func isRecoverableError(error: HttpAddressErrorType): bool {....raises: [], tags: [].}
- Source Edit
proc newHttpInterruptError(): ref HttpInterruptError {.noinline, ...raises: [], tags: [].}
- Source Edit
proc newHttpReadError(message: string): ref HttpReadError {.noinline, ...raises: [], tags: [].}
- Source Edit
proc newHttpUseClosedError(): ref HttpUseClosedError {.noinline, ...raises: [], tags: [].}
- Source Edit
proc newHttpWriteError(message: string): ref HttpWriteError {.noinline, ...raises: [], tags: [].}
- Source Edit
proc raiseHttpAddressError(msg: string) {.noinline, noreturn, ...raises: [HttpAddressError], raises: [], tags: [].}
- Source Edit
proc raiseHttpConnectionError(msg: string) {.noinline, noreturn, ...raises: [HttpConnectionError], raises: [], tags: [].}
- Source Edit
proc raiseHttpCriticalError(msg: string; code = Http400) {.noinline, noreturn, ...raises: [HttpCriticalError], deprecated, raises: [], tags: [].}
- Source Edit
proc raiseHttpDisconnectError() {.noinline, noreturn, ...raises: [HttpDisconnectError], raises: [], tags: [].}
- Source Edit
proc raiseHttpInterruptError() {.noinline, noreturn, ...raises: [HttpInterruptError], raises: [], tags: [].}
- Source Edit
proc raiseHttpProtocolError(code: HttpCode; msg: string) {.noinline, noreturn, ...raises: [HttpProtocolError], raises: [], tags: [].}
- Source Edit
proc raiseHttpProtocolError(msg: HttpMessage) {.noinline, noreturn, ...raises: [HttpProtocolError], raises: [], tags: [].}
- Source Edit
proc raiseHttpProtocolError(msg: string) {.noinline, noreturn, ...raises: [HttpProtocolError], raises: [], tags: [].}
- Source Edit
proc raiseHttpReadError(msg: string) {.noinline, noreturn, ...raises: [HttpReadError], raises: [], tags: [].}
- Source Edit
proc raiseHttpRedirectError(msg: string) {.noinline, noreturn, ...raises: [HttpRedirectError], raises: [], tags: [].}
- Source Edit
proc raiseHttpRequestBodyTooLargeError() {.noinline, noreturn, ...raises: [HttpRequestBodyTooLargeError], raises: [], tags: [].}
- Source Edit
proc raiseHttpWriteError(msg: string) {.noinline, noreturn, ...raises: [HttpWriteError], raises: [], tags: [].}
- Source Edit
func stringToBytes(src: openArray[char]): seq[byte] {....raises: [], tags: [].}
-
Convert string to sequence of bytes.
Note, that this procedure assume that sizeof(byte) == sizeof(char) == 1. If this equation is not correct this procedures MUST not be used.
Source Edit proc stringToBytes(src: openArray[char]; dst: var openArray[byte]) {....raises: [], tags: [].}
-
Convert array of characters to array of bytes.
Note, that this procedure assume that sizeof(byte) == sizeof(char) == 1. If this equation is not correct this procedures MUST not be used.
Source Edit func toString(error: HttpAddressErrorType): string {....raises: [], tags: [].}
- Source Edit
Iterators
iterator queryParams(query: string; flags: set[QueryParamsFlag] = {}): KeyValueTuple {. ...raises: [], tags: [].}
- Iterate over url-encoded query string. Source Edit
Exports
-
setThreadDispatcher, closeSocket, ENOSR, EHOSTUNREACH, EHOSTDOWN, ECONNRESET, EDQUOT, fail, ECANCELED, EMLINK, FuturePendingError, milliseconds, <=, +=, $, asyncTimer, internalRaiseIfError, getSrcLocation, FutureError, fromNow, weeks, ESPIPE, withTimeout, LocationKind, id, <=, FutureCompletedError, ENOEXEC, ESHUTDOWN, fail, EREMOTEIO, toString, EDESTADDRREQ, waitFor, complete, internalInitFutureBase, EPROTONOSUPPORT, Nanosecond, cancelAndWait, addTimer, Moment, ECOMM, EPROTOTYPE, AsyncExceptionError, milliseconds, getTrackerCounter, ENOENT, millis, removeTimer, ==, FutureFlag, ENOTCONN, EBUSY, init, ENOTUNIQ, days, +=, race, or, EKEYREVOKED, AsyncTimeoutError, EUCLEAN, Second, EEXIST, ENOLINK, newInternalRaisesFuture, idleAsync, internalRaiseIfError, SomeIntegerI64, ENOMEM, ENOKEY, +, removeWriter2, ENOMSG, [], trackCounter, EKEYEXPIRED, Week, isCounterLeaked, awaitne, EAFNOSUPPORT, EWOULDBLOCK, EREMOTE, finished, untrackCounter, AsyncCallback, EHWPOISON, epochSeconds, newDispatcher, EPERM, microseconds, trackerCounters, internalFail, weeks, Finished, cancelCallback=, ETOOMANYREFS, $, EISCONN, callSoon, ESOCKTNOSUPPORT, setGlobalDispatcher, EXDEV, EBADF, cancelSoon, allFinished, TrackerBase, hours, InternalAsyncCallback, EBFONT, ENETDOWN, EACCES, ELOOP, InfiniteDuration, ETIMEDOUT, EINVAL, value, EBADFD, Future, completed, PDispatcher, ESRCH, EL2NSYNC, Finished, low, ESTRPIPE, -=, ==, ENOTSOCK, getAsyncTimestamp, SrcLoc, Hour, EIDRM, removeReader2, secs, getThreadDispatcher, futureContinue, isZero, ENOANO, EADV, CallbackFunc, contains, cancelAndWait, $, ENFILE, FutureBase, waitFor, high, Microsecond, ENOPKG, ELIBBAD, callSoon, EOWNERDEAD, ERANGE, done, or, ENONET, completed, callSoon, cancelSoon, EMSGSIZE, EALREADY, EBADMSG, EILSEQ, ENOPROTOOPT, EXFULL, allFutures, -, complete, FutureState, EBADR, nanos, location, FutureDefect, EDOTDOT, ENOBUFS, EKEYREJECTED, <, Minute, error, one, CancelledError, nanoseconds, EISDIR, sleepAsync, EOVERFLOW, FutureSeq, cancelAndWait, micros, -, ESRMNT, ENOTEMPTY, race, TimerCallback, microseconds, error, ENOTRECOVERABLE, wait, callIdle, EDOM, value, hours, AsyncError, EBADRQC, ENODEV, tryCancel, addTimer, ECHRNG, ENOTDIR, EUNATCH, cancelAndSchedule, failed, nanoseconds, ERESTART, *, ETXTBSY, getTracker, newFutureStr, EMFILE, LocFinishIndex, withTimeout, addTimer, await, EUSERS, ENOTBLK, EISNAM, ELIBACC, ENAVAIL, init, race, internalCallTick, ==, Day, +, cancelSoon, completed, minutes, cancel, FutureFlags, getGlobalDispatcher, ELIBEXEC, stepsAsync, micros, wait, cancelAndWait, EINPROGRESS, EPFNOSUPPORT, E2BIG, -=, runForever, ENOMEDIUM, secs, read, waitFor, EL3HLT, unregisterAndCloseFd, EBADSLT, -, <, ENETRESET, fastEpochTime, ENXIO, join, EPIPE, allFutures, EPROTO, ENOTTY, wait, now, read, asyncSpawn, removeCallback, EAGAIN, raiseOsDefect, trackerCounterKeys, EADDRNOTAVAIL, read, removeCallback, TrackerCounter, async, addCallback, init, async, ZeroDuration, EREMCHG, EFAULT, addCallback, seconds, noCancel, low, AsyncFD, ECHILD, Raising, init, ECONNABORTED, state, wait, callIdle, removeTimer, LocCreateIndex, addReader2, ETIME, ENOLCK, EDEADLK, asyncCheck, Duration, ELNRNG, ENOCSI, millis, EBADE, EMEDIUMTYPE, readError, sleepAsync, isInfinite, callback=, ENETUNREACH, InternalFutureBase, callIdle, ENOSPC, ENOSYS, ELIBSCN, EIO, EROFS, seconds, ELIBMAX, await, div, init, EL2HLT, EOPNOTSUPP, FutureStr, poll, flags, clearTimer, register2, LocCompleteIndex, days, ENOSTR, EADDRINUSE, one, ENAMETOOLONG, EMULTIHOP, epochNanoSeconds, ESTALE, race, ENODATA, EFBIG, +, minutes, ERFKILL, cancelled, toException, InternalRaisesFuture, EDEADLOCK, allFutures, MaxEventsCount, wait, read, raiseAsDefect, Millisecond, setTimer, cancelSoon, unregister2, failed, waitFor, newFutureSeq, addTracker, callback=, orImpl, ECONNREFUSED, high, ENOTNAM, nanos, addWriter2, removeTimer, internalCallTick, EINTR, join, closeHandle, EL3RST, readError, *, newFuture, internalCallTick, []=, EDQUOT, availableSlots, Second, closeSocket, EHOSTUNREACH, EHOSTDOWN, closeWait, ECONNRESET, ==, fail, ECANCELED, EMLINK, milliseconds, FutureBase, <=, +=, $, asyncTimer, internalRaiseIfError, getSrcLocation, FutureError, fromNow, close, weeks, LocFinishIndex, ESPIPE, withTimeout, LocationKind, id, isSet, <=, FutureCompletedError, SomeIntegerI64, fail, EREMOTEIO, EPROTO, waitFor, addTimer, internalInitFutureBase, EPROTONOSUPPORT, nanoseconds, cancelAndWait, contains, ENOPKG, Moment, ECOMM, addFirst, register, EPROTOTYPE, AsyncExceptionError, AsyncSemaphore, SrcLoc, ENOCSI, milliseconds, getTrackerCounter, ENOENT, millis, removeTimer, ELIBACC, EADDRNOTAVAIL, ENOTCONN, EBUSY, init, waitFor, days, +=, EXFULL, EAFNOSUPPORT, ZeroDuration, cancelSoon, AsyncTimeoutError, internalCallTick, []=, setThreadDispatcher, EEXIST, isInfinite, ENOLINK, newInternalRaisesFuture, idleAsync, internalRaiseIfError, ESHUTDOWN, ENOMEM, ENOKEY, +, removeWriter2, ENOMSG, [], trackCounter, EKEYEXPIRED, Week, isCounterLeaked, awaitne, EWOULDBLOCK, EREMOTE, unregister, tryAcquire, finished, untrackCounter, AsyncCallback, EHWPOISON, epochSeconds, newDispatcher, EPERM, microseconds, trackerCounters, internalFail, sleepAsync, addCallback, weeks, Finished, callIdle, cancelCallback=, ETOOMANYREFS, mitems, EISCONN, callSoon, ESOCKTNOSUPPORT, newAsyncQueue, setGlobalDispatcher, AsyncQueue, release, EXDEV, EBADF, EKEYREVOKED, micros, microseconds, hours, wait, ENETDOWN, EACCES, AsyncEvent, AsyncEventQueue, ELOOP, InfiniteDuration, ETIMEDOUT, clear, EINVAL, value, EALREADY, EBADFD, Future, addCallback, len, completed, PDispatcher, ESRCH, EL2NSYNC, Finished, low, newAsyncEvent, ESTRPIPE, -=, EBADE, [], getAsyncTimestamp, div, await, Hour, EIDRM, removeReader2, EventQueueReader, secs, getThreadDispatcher, EventQueueKey, futureContinue, popFirstNoWait, isZero, ENOANO, readError, CallbackFunc, cancelAndWait, $, FutureStr, addLastNoWait, ENOEXEC, waitFor, high, Microsecond, complete, $, pairs, ELIBBAD, callSoon, EOWNERDEAD, ERANGE, done, clearTimer, popLastNoWait, contains, or, ENONET, completed, callSoon, release, cancelSoon, EMSGSIZE, EBADMSG, EILSEQ, ENOPROTOOPT, ENOTTY, allFutures, empty, -, addTimer, FutureState, addFirstNoWait, EBADR, nanos, location, FutureDefect, EDOTDOT, ENOBUFS, put, EKEYREJECTED, <, Minute, error, ENOLCK, one, CancelledError, EISDIR, epochNanoSeconds, EOVERFLOW, FutureSeq, cancelAndWait, micros, -, ESRMNT, ENOTEMPTY, await, TimerCallback, TrackerBase, or, ENOTRECOVERABLE, EBFONT, callIdle, cancelAndWait, hours, AsyncError, EBADRQC, ENODEV, ENFILE, complete, callback=, ECHRNG, wait, EUNATCH, cancelAndSchedule, acquire, failed, nanoseconds, ERESTART, *, ETXTBSY, getTracker, newFutureStr, full, EMFILE, orImpl, withTimeout, InternalRaisesFuture, addTimer, race, EUSERS, ENOTBLK, race, EISNAM, ENOSR, init, race, EUCLEAN, Day, +, cancelSoon, minutes, cancel, FutureFlags, getGlobalDispatcher, ELIBEXEC, stepsAsync, error, allFinished, wait, clear, EINPROGRESS, completed, E2BIG, -=, runForever, ENOMEDIUM, secs, AsyncQueueEmptyError, value, read, waitFor, EINTR, newAsyncSemaphore, unregisterAndCloseFd, EBADSLT, [], -, <, ENETRESET, fastEpochTime, waitEvents, seconds, EDOM, FuturePendingError, EPIPE, AsyncLockError, InternalFutureBase, getNoWait, allFutures, len, EDESTADDRREQ, ENAVAIL, EPFNOSUPPORT, wait, EMULTIHOP, read, asyncSpawn, removeCallback, EAGAIN, raiseOsDefect, trackerCounterKeys, FutureFlag, read, removeCallback, TrackerCounter, async, AsyncLock, init, popLast, async, ENOSPC, EREMCHG, EFAULT, fire, ENXIO, seconds, noCancel, low, AsyncFD, ECHILD, init, ECONNABORTED, state, ENOTDIR, callIdle, removeTimer, LocCreateIndex, setTimer, ETIME, EDEADLK, items, cancelSoon, asyncCheck, unregister2, Duration, ELNRNG, locked, join, millis, ==, EMEDIUMTYPE, readError, sleepAsync, newFutureSeq, newAsyncEventQueue, InternalAsyncCallback, ENETUNREACH, get, ENOSYS, acquire, ELIBSCN, EIO, EROFS, AsyncEventQueueFullError, ELIBMAX, race, EFBIG, EL2HLT, AsyncQueueFullError, EOPNOTSUPP, emit, tryCancel, poll, readerOverflow, flags, register2, LocCompleteIndex, newAsyncLock, days, ENOSTR, EADDRINUSE, one, AsyncSemaphoreError, size, newFuture, now, putNoWait, Nanosecond, wait, popFirst, ESTALE, Raising, ENODATA, init, +, minutes, ERFKILL, cancelled, $, toException, ==, EDEADLOCK, allFutures, MaxEventsCount, wait, read, raiseAsDefect, Millisecond, addLast, addReader2, failed, ENOTUNIQ, addTracker, callback=, ENOTSOCK, ECONNREFUSED, high, ENOTNAM, nanos, addWriter2, toString, removeTimer, internalCallTick, EL3HLT, join, closeHandle, EL3RST, EADV, *, ENAMETOOLONG, internalCallTick