From 608fcc4075c1f28207aa177ec2d9408cc3e5e0da Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 22 Nov 2020 16:21:36 +0100 Subject: Added HTTP response things Very specific. --- apps/server.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'apps') 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 +#include #include #include #include #define PORT 8000 -#define RESP "HTTP/1.1 200\r\nContent-Length: 14\r\nConnection: close\r\n\r\n

Hallo

" +#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); } -- cgit v1.2.3