diff options
author | bptato <nincsnevem662@gmail.com> | 2022-08-08 18:11:42 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-08-08 18:11:54 +0200 |
commit | e2203257e07aada157be9d0a948273cb9d683072 (patch) | |
tree | 1b50351e0e9d0f6843a46c48aad3338a067384e8 /src/io/buffer.nim | |
parent | e7ea9c408667a4fdfefc369e51d72c3cfb9c1ee9 (diff) | |
download | chawan-e2203257e07aada157be9d0a948273cb9d683072.tar.gz |
Refactor fileloader
Diffstat (limited to 'src/io/buffer.nim')
-rw-r--r-- | src/io/buffer.nim | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/io/buffer.nim b/src/io/buffer.nim index c9cb64a0..08feb73f 100644 --- a/src/io/buffer.nim +++ b/src/io/buffer.nim @@ -933,8 +933,8 @@ type url*: string httpmethod*: HttpMethod mimetype*: string - body*: string - multipart*: MimeData + body*: Option[string] + multipart*: Option[MimeData] # https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#constructing-the-form-data-set proc constructEntryList(form: HTMLFormElement, submitter: Element = nil, encoding: string = ""): Table[string, string] = @@ -1029,7 +1029,6 @@ proc makeCRLF(s: string): string = inc i proc serializeMultipartFormData(kvs: Table[string, string]): MimeData = - new(result) for name, value in kvs: let name = makeCRLF(name) let value = makeCRLF(value) @@ -1080,18 +1079,18 @@ proc submitForm(form: HTMLFormElement, submitter: Element): Option[ClickAction] return ClickAction(url: $parsedaction, httpmethod: httpmethod).some template submitAsEntityBody() = - var body: string var mimetype: string - var multipart: MimeData + var body = none(string) + var multipart = none(MimeData) case enctype of FORM_ENCODING_TYPE_URLENCODED: - body = serializeApplicationXWWFormUrlEncoded(entrylist) + body = serializeApplicationXWWFormUrlEncoded(entrylist).some mimeType = $enctype of FORM_ENCODING_TYPE_MULTIPART: - multipart = serializeMultipartFormData(entrylist) + multipart = serializeMultipartFormData(entrylist).some mimetype = $enctype of FORM_ENCODING_TYPE_TEXT_PLAIN: - body = serializePlainTextFormData(entrylist) + body = serializePlainTextFormData(entrylist).some mimetype = $enctype return ClickAction(url: $parsedaction, httpmethod: httpmethod, body: body, mimetype: mimetype, multipart: multipart).some |