aboutsummaryrefslogtreecommitdiff
path: root/apps/server.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/server.c')
-rw-r--r--apps/server.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/apps/server.c b/apps/server.c
index 3d3bb77..4840da3 100644
--- a/apps/server.c
+++ b/apps/server.c
@@ -33,11 +33,17 @@ int main()
memset(buf, 0, 4096);
- u32 len = 0;
- if ((len = stat(path)))
- len = http_response(HTTP_200, len, read(path), buf);
+ struct stat s_file = { 0 };
+ int res_file = stat(path, &s_file);
+
+ struct stat s_error = { 0 };
+ stat(path, &s_error);
+
+ int len;
+ if (res_file && s_file.size)
+ len = http_response(HTTP_200, s_file.size, sread(path), buf);
else
- len = http_response(HTTP_404, stat(ERROR), read(ERROR), buf);
+ len = http_response(HTTP_404, s_error.size, sread(ERROR), buf);
net_send(socket, buf, len);
net_close(socket);