diff --git a/lib/kc3/0.1/httpd.kc3 b/lib/kc3/0.1/httpd.kc3
index 83ebea3..ac4224f 100644
--- a/lib/kc3/0.1/httpd.kc3
+++ b/lib/kc3/0.1/httpd.kc3
@@ -2,13 +2,10 @@ defmodule HTTPd do
def server_loop = fn (client) {
puts("HTTPd.server_loop: got client #{client}")
- ok = true
- req = true
- while req do
- req = HTTP.Request.buf_parse(client.buf_rw.r)
- if req do
- puts("HTTPd.server_loop: got request #{req}")
- res = %HTTP.Response{body: "<html>
+ req = HTTP.Request.buf_parse(client.buf_rw.r)
+ if req do
+ puts("HTTPd.server_loop: got request #{req}")
+ res = %HTTP.Response{body: "<html>
<head>
<title>KC3 HTTPd</title>
</head>
@@ -22,13 +19,8 @@ defmodule HTTPd do
</body>
</html>
"}
- puts("HTTPd.server_loop: response: #{res}")
- if (HTTP.Response.buf_write(res, client.buf_rw.w) < 0) do
- req = false
- end
- else
- ok = false
- end
+ puts("HTTPd.server_loop: response: #{res}")
+ HTTP.Response.buf_write(res, client.buf_rw.w)
end
}
@@ -38,6 +30,7 @@ defmodule HTTPd do
while true do
client = Socket.Buf.accept(socket)
server_loop(client)
+ Socket.Buf.close(client)
end
}
diff --git a/test/http/04_server_request.kc3 b/test/http/04_server_request.kc3
index 642ec56..e68172f 100644
--- a/test/http/04_server_request.kc3
+++ b/test/http/04_server_request.kc3
@@ -12,9 +12,9 @@ quote response = %HTTP.Response{body: "Hello, KC3 HTTP test server !"}
response = %HTTP.Response{body: "Hello, KC3 HTTP test server !"}
quote HTTP.Response.buf_write(response, client.buf_rw.w)
HTTP.Response.buf_write(response, client.buf_rw.w)
-quote Socket.Buf.close(client)
-Socket.Buf.close(client)
-quote Socket.Buf.close(server_client)
-Socket.Buf.close(server_client)
-quote Socket.close(server)
-Socket.close(server)
+#quote Socket.Buf.close(client)
+#Socket.Buf.close(client)
+#quote Socket.Buf.close(server_client)
+#Socket.Buf.close(server_client)
+#quote Socket.close(server)
+#Socket.close(server)