about summary refs log tree commit diff stats
path: root/src/io
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-05 09:32:58 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-05 09:44:14 +0100
commit302e6cd0bd687709b33e0885302c76182bc74918 (patch)
tree498be8bb45a863d15a4a1215163a19a5fed64690 /src/io
parent4137297efe003cec8e4d9eed810d1f801a21dfce (diff)
downloadchawan-302e6cd0bd687709b33e0885302c76182bc74918.tar.gz
Add -M, -V
Diffstat (limited to 'src/io')
-rw-r--r--src/io/about.nim23
-rw-r--r--src/io/loader.nim3
2 files changed, 26 insertions, 0 deletions
diff --git a/src/io/about.nim b/src/io/about.nim
new file mode 100644
index 00000000..f90e0c36
--- /dev/null
+++ b/src/io/about.nim
@@ -0,0 +1,23 @@
+import streams
+import tables
+
+import io/request
+import ips/serialize
+import types/url
+
+const cha = staticRead"res/cha.html"
+const Headers = {
+  "Content-Type": "text/html"
+}.toTable()
+
+proc loadAbout*(request: Request, ostream: Stream) =
+  if request.url.pathname == "cha":
+    ostream.swrite(0)
+    ostream.swrite(200) # ok
+    let headers = newHeaderList(Headers)
+    ostream.swrite(headers)
+    ostream.write(cha)
+  else:
+    ostream.swrite(-1)
+  ostream.flush()
+
diff --git a/src/io/loader.nim b/src/io/loader.nim
index 217ab88f..f9964845 100644
--- a/src/io/loader.nim
+++ b/src/io/loader.nim
@@ -19,6 +19,7 @@ when defined(posix):
   import posix
 
 import bindings/curl
+import io/about
 import io/http
 import io/request
 import ips/serialize
@@ -75,6 +76,8 @@ proc loadResource(request: Request, ostream: Stream) =
     loadFile(request.url, ostream)
   of "http", "https":
     loadHttp(request, ostream)
+  of "about":
+    loadAbout(request, ostream)
   else:
     ostream.swrite(-1) # error
     ostream.flush()