From 0b26036fae0f4280e1dadc343147edb9de9bc0e3 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 15:41:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/server.c b/server.c index 192c250..70ae616 100644 --- a/server.c +++ b/server.c @@ -73,8 +73,7 @@ void accept_request(void *cli) { return; } - if (strcasecmp(method, "POST") == 0) - cgi = 1; + if (strcasecmp(method, "POST") == 0) cgi = 1; i = 0; while (ISspace(buf[j]) && (j < sizeof(buf))) @@ -155,8 +154,7 @@ void cat(int client, FILE *resource) { char buf[1024]; size_t size = 0; - while ((size = fread(buf, sizeof(char), 1024, resource))) - send(client, buf, size, 0); + while ((size = fread(buf, sizeof(char), 1024, resource))) send(client, buf, size, 0); } /**********************************************************************/ @@ -360,11 +358,9 @@ void headers(int client, const char *filepath) { uint offset = 0; uint extpos = strlen(filepath) - 4; - ADD_HERDER(HTTP200); - ADD_HERDER(SERVER_STRING); + ADD_HERDER(HTTP200 SERVER_STRING); ADD_HERDER_PARAM(CONTENT_TYPE, EXTNM_IS_NOT("html")?(EXTNM_IS_NOT(".css")?"text/plain":"text/css"):"text/html"); - ADD_HERDER_PARAM(CONTENT_LEN, get_file_size(filepath)); - ADD_HERDER("\r\n"); + ADD_HERDER_PARAM(CONTENT_LEN "\r\n", get_file_size(filepath)); send(client, buf, offset, 0); }