diff options
author | Marvin Borner | 2020-11-22 16:21:36 +0100 |
---|---|---|
committer | Marvin Borner | 2020-11-22 16:21:36 +0100 |
commit | 608fcc4075c1f28207aa177ec2d9408cc3e5e0da (patch) | |
tree | f526124c6ebcdb5895c074f2296eec5900622ef3 /apps | |
parent | 9b739062e9e0a10770d5f6c11d65649671031374 (diff) |
Added HTTP response things
Very specific.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/server.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/apps/server.c b/apps/server.c index ceb5ed0..5c94a88 100644 --- a/apps/server.c +++ b/apps/server.c @@ -1,12 +1,13 @@ // MIT License, Copyright (c) 2020 Marvin Borner #include <assert.h> +#include <mem.h> #include <net.h> #include <print.h> #include <str.h> #define PORT 8000 -#define RESP "HTTP/1.1 200\r\nContent-Length: 14\r\nConnection: close\r\n\r\n<h1>Hallo</h1>" +#define FILE "/res/index.html" int main() { @@ -19,7 +20,9 @@ int main() socket->state = S_CONNECTED; char buf[4096] = { 0 }; net_receive(socket, buf, 4096); - net_send(socket, strdup(RESP), strlen(RESP)); + memset(buf, 0, 4096); + int l = http_response(HTTP_200, stat(FILE), read(FILE), buf); + net_send(socket, buf, l); net_close(socket); } |