summaryrefslogtreecommitdiff
path: root/lib/http
diff options
context:
space:
mode:
Diffstat (limited to 'lib/http')
-rw-r--r--lib/http/server.myr8
-rw-r--r--lib/http/session.myr4
2 files changed, 5 insertions, 7 deletions
diff --git a/lib/http/server.myr b/lib/http/server.myr
index 220f56d..34c0eef 100644
--- a/lib/http/server.myr
+++ b/lib/http/server.myr
@@ -29,10 +29,10 @@ const announce = {ds
}
const serve = {srv
- std.put("waiting for connection\n")
while true
match waitconn(srv)
- | `std.Ok fd: communicate(srv, fd)
+ | `std.Ok fd:
+ thread.spawn({;communicate(srv, fd)})
| `std.Err e: /* eh? */
;;
;;
@@ -47,7 +47,6 @@ const communicate = {srv, fd
| `std.Ok req:
dispatch(srv, s, req)
| `std.Err e:
- std.put("failed to parse request: {}\n", e)
break
;;
;;
@@ -57,14 +56,13 @@ const communicate = {srv, fd
const dispatch = {srv, sess, req
var resp : resp#
- std.put("got req: {}\n", req)
resp = std.mk([
.status=200,
.hdrs = [][:],
.len = 0,
.err = `std.None,
.reason = "",
- .body = "heard you loud and clear\n",
+ .body = "pong\n",
.enc = `Length
])
respond(srv, sess, resp)
diff --git a/lib/http/session.myr b/lib/http/session.myr
index 32ec8eb..50cf893 100644
--- a/lib/http/session.myr
+++ b/lib/http/session.myr
@@ -4,7 +4,7 @@ use bio
use "types"
pkg http =
- const mksession : (schema : schema, host : byte[:], port : int -> std.result(session#, err))
+ const mksession : (schema : schema, host : byte[:], port : uint16 -> std.result(session#, err))
const mksrvsession : (fd : std.fd -> session#)
const freesession : (s : session# -> void)
@@ -42,7 +42,7 @@ const mksrvsession = {fd
-> std.mk([
.err = false,
.srvname = std.sldup("Myrfoo HTTP Server"),
- .f = bio.mkfile(fd, bio.Rw)
+ .f = bio.mkfile(fd, bio.Rw),
])
}