guildenstern/multipartserver

Multipart/formdata server

see examples/multiparttest.nim for a concrete example.

Types

PartState = enum
  HeaderReady,              ## New part starts. [parseContentDisposition] is your friend here. For accessing other fields, use http.headers
  BodyChunk,                ## More data for the current part body has arrived
  BodyReady,                ## Current part is received
  Failed,                   ## See contents of chunk for potential additional info
  Completed                  ## That's it
State of the request delivery inside the receiveParts iterator

Procs

proc newMultipartServer(onrequestcallback: proc () {....gcsafe, nimcall, ...raises: [].};
                        loglevel = LogLevel.WARN;
                        headerfields: openArray[string] = []): HttpServer {.
    ...raises: [], tags: [], forbids: [].}
Note: headerfields concern only the whole request, not part headers
proc parseContentDisposition(): (string, string) {....raises: [], tags: [],
    forbids: [].}
Returns values of name and filename properties of the content-disposition header field

Iterators

iterator receiveParts(parsepartheaders: bool = true): (PartState, string) {.
    ...raises: [], tags: [RootEffect], forbids: [].}
Iterator for streaming in multipart/formdata