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
Exports
-
shortdivider, prepareHttpContext, checkSocketState, closeSocket, reply, shutdown, reply, server, isUri, replyStartChunked, parseMethod, MSG_DONTWAIT, parseRequestLine, replyFinish, MSG_MORE, reply, CloseOtherSocketCallback, readHeader, replyFinishChunked, replyContinueChunked, SocketCloseCause, receiveStream, reply, handleRead, isHttpContext, getRequest, initializeThread, $, LogLevel, GuildenSternVersion, getBodylen, SocketState, getMethod, OnCloseSocketCallback, SocketContext, newHttpServer, shuttingdown, replyMore, reply, startsUri, initialize, handleHttpThreadInitialization, socketcontext, getContentLength, replyStart, reply, reply, http, longdivider, HandlerCallback, reply, LogCallback, HttpServer, reply, SocketData, initHttpServer, getUri, replyMore, getBody, shutdownevent, suspend, isMethod, HttpContext, closeOtherSocket, ThreadInitializerCallback, GuildenServer, CloseSocketCallback, ContentType, SuspendCallback, replyStart, log, isBody, isHeaderreceived