From 7553bd8e7abf7722a46709c164d4ae54c393f863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 7 Jun 2021 22:20:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=BA=9Blog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/server.c b/server.c index b48e210..63fe8f4 100644 --- a/server.c +++ b/server.c @@ -120,10 +120,8 @@ void accept_request(void *cli) { (st.st_mode & S_IXGRP) || (st.st_mode & S_IXOTH)) cgi = 1; - if (!cgi) - serve_file(client, path); - else - execute_cgi(client, path, method, query_string); + if (!cgi) serve_file(client, path); + else execute_cgi(client, path, method, query_string); } close(client); @@ -293,10 +291,11 @@ void execute_cgi(int client, const char *path, const char *method, const char *q /**********************************************************************/ off_t get_file_size(const char *filepath) { struct stat statbuf; - if (stat(filepath, &statbuf) == 0) + if (stat(filepath, &statbuf) == 0) { + printf("file size: %u\n", statbuf.st_size); return statbuf.st_size; - else - return -1; + } + else return -1; } /**********************************************************************/