aboutsummaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-24 20:43:19 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-24 21:45:23 +0100
commitcc7eacf75ebee5b3846e26b4fe338279a34bf939 (patch)
tree1f805566927f79ba2500e039561d93c18b00e7f9 /src/server
parent78a977b76dc4cb695f406666e035c880cce8cdd5 (diff)
downloadchawan-cc7eacf75ebee5b3846e26b4fe338279a34bf939.tar.gz
js: proper distinction between Opt/Option
until now, this had very strange (and inconsistent) semantics: * err() was used for exception propagation, but also as a null value * Option accepted undefined as a none value, but not null * Opt and Option were used interchangeably (and mostly randomly) Now, Result is always used for error reporting, and err(nil) means JS_EXCEPTION. (Opt is a special case of Result where we don't care about the error type, and is not used in JS.) Option on the other hand means "nullable variation of normally non-nullable type", and translates to JS_NULL. In JS we mainly use it for turning strings nullable.
Diffstat (limited to 'src/server')
-rw-r--r--src/server/buffer.nim12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/server/buffer.nim b/src/server/buffer.nim
index fe2201e6..13a7ea20 100644
--- a/src/server/buffer.nim
+++ b/src/server/buffer.nim
@@ -1200,7 +1200,7 @@ proc serializeMultipartFormData(entries: seq[FormDataEntry]): FormData =
let value = makeCRLF(entry.svalue)
formData.append(name, value)
else:
- formData.append(name, entry.value, opt(entry.filename))
+ formData.append(name, entry.value, some(entry.filename))
return formData
proc serializePlainTextFormData(kvs: seq[(string, string)]): string =
@@ -1274,22 +1274,22 @@ proc submitForm(form: HTMLFormElement, submitter: Element): Option[Request] =
template submitAsEntityBody() =
var mimetype: string
- var body: Opt[string]
- var multipart: Opt[FormData]
+ var body: Option[string]
+ var multipart: Option[FormData]
case enctype
of FORM_ENCODING_TYPE_URLENCODED:
#TODO with charset
let kvlist = entrylist.toNameValuePairs()
- body.ok(serializeApplicationXWWWFormUrlEncoded(kvlist))
+ body = some(serializeApplicationXWWWFormUrlEncoded(kvlist))
mimeType = $enctype
of FORM_ENCODING_TYPE_MULTIPART:
#TODO with charset
- multipart.ok(serializeMultipartFormData(entrylist))
+ multipart = some(serializeMultipartFormData(entrylist))
mimetype = $enctype
of FORM_ENCODING_TYPE_TEXT_PLAIN:
#TODO with charset
let kvlist = entrylist.toNameValuePairs()
- body.ok(serializePlainTextFormData(kvlist))
+ body = some(serializePlainTextFormData(kvlist))
mimetype = $enctype
let req = newRequest(parsedaction, httpmethod, @{"Content-Type": mimetype},
body, multipart)