diff options
author | Nathan Lasseter <nathan@4574.co.uk> | 2013-10-24 21:08:50 +0100 |
---|---|---|
committer | Nathan Lasseter <nathan@4574.co.uk> | 2013-10-24 21:08:50 +0100 |
commit | f3ee7526e1f04ccee1f1a4d3a775e2ce75169926 (patch) | |
tree | c49717071752e759ec7e63f002bbbdccc7d3338d /server.d | |
parent | 8480e8287fdf3aa933ad7b82457b3e67ab0bfa0b (diff) |
Initial implementation of client context, headers not working.
Diffstat (limited to 'server.d')
-rw-r--r-- | server.d | 18 |
1 files changed, 4 insertions, 14 deletions
@@ -1,7 +1,5 @@ -import std.socket, std.stdio, - std.conv, std.file, - std.string; -import serverutils; +import std.socket, std.conv; +import context; void main(string[] args) { if (args.length != 2) return; @@ -9,17 +7,9 @@ void main(string[] args) { sock.bind(new InternetAddress("127.0.0.1", to!ushort(args[1]))); sock.listen(1000); while (true) { - auto level = 0; auto pair = sock.accept(); - char[255] filename; - auto len = pair.receive(filename); - auto file = filename[0 .. len]; - file = strip(file); - if (inRoot(file)) { - pair.send(readText(file)); - } else { - pair.send("ERROR: Client left root!\n"); - } + auto context = new ClientContext(pair); + context.handle(); pair.shutdown(SocketShutdown.BOTH); pair.close(); } |