about summary refs log tree commit diff stats
path: root/src/loader
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-09-01 16:35:51 +0200
committerbptato <nincsnevem662@gmail.com>2024-09-01 17:07:05 +0200
commitd07187fc186681e262afd67bd748206e40aef346 (patch)
treebef16c305013311c01f4ee821d03dc2550b75a95 /src/loader
parentd1ff49b0fc39171859cfa781f459a2e0242c2e79 (diff)
downloadchawan-d07187fc186681e262afd67bd748206e40aef346.tar.gz
canvas: make sure we don't link to QJS
Diffstat (limited to 'src/loader')
-rw-r--r--src/loader/request.nim20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/loader/request.nim b/src/loader/request.nim
index 2af5dcf3..c210898d 100644
--- a/src/loader/request.nim
+++ b/src/loader/request.nim
@@ -2,6 +2,8 @@ import std/options
 import std/tables
 
 import html/script
+import io/bufreader
+import io/bufwriter
 import loader/headers
 import monoucha/fromjs
 import monoucha/javascript
@@ -90,6 +92,24 @@ type
 
 jsDestructor(JSRequest)
 
+proc swrite*(writer: var BufferedWriter; o: RequestBody) =
+  writer.swrite(o.t)
+  case o.t
+  of rbtNone: discard
+  of rbtString: writer.swrite(o.s)
+  of rbtMultipart: writer.swrite(o.multipart)
+  of rbtOutput: writer.swrite(o.outputId)
+
+proc sread*(reader: var BufferedReader; o: var RequestBody) =
+  var t: RequestBodyType
+  reader.sread(t)
+  o = RequestBody(t: t)
+  case t
+  of rbtNone: discard
+  of rbtString: reader.sread(o.s)
+  of rbtMultipart: reader.sread(o.multipart)
+  of rbtOutput: reader.sread(o.outputId)
+
 proc contentLength*(body: RequestBody): int =
   case body.t
   of rbtNone: return 0