From 4c981a4fd5d8b63d0f28f9f4445f475eaf781cba Mon Sep 17 00:00:00 2001 From: freakkid <904811062@qq.com> Date: Fri, 25 Jan 2019 20:52:37 +0800 Subject: [PATCH] fix cat #31 --- httpd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/httpd.c b/httpd.c index d4eb456..b9ffd7b 100644 --- a/httpd.c +++ b/httpd.c @@ -164,11 +164,9 @@ void cat(int client, FILE *resource) { char buf[1024]; - fgets(buf, sizeof(buf), resource); - while (!feof(resource)) + while (fgets(buf, sizeof(buf), resource) != NULL) { send(client, buf, strlen(buf), 0); - fgets(buf, sizeof(buf), resource); } }