From d4603077a10555d620c94a614d0546d6959f2a48 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:11:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96cgi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/server.c b/server.c index f1841cc..192c250 100644 --- a/server.c +++ b/server.c @@ -255,13 +255,11 @@ void execute_cgi(int client, const char *path, const char *method, const char *q sprintf(query_env, "QUERY_STRING=%s", query_string); putenv(query_env); } - else - { /* POST */ + else { /* POST */ sprintf(length_env, "CONTENT_LENGTH=%d", content_length); putenv(length_env); } - //if(strcmp(path, "./sockjs-node/info") == 0) execl("cat", "./sockjs-node/info.json", 0); - execl(path, path, NULL); + execl(path, path, method, query_string, NULL); exit(0); } else { /* parent */ @@ -272,8 +270,7 @@ void execute_cgi(int client, const char *path, const char *method, const char *q recv(client, &c, 1, 0); write(cgi_input[1], &c, 1); } - while (read(cgi_output[0], &c, 1) > 0) - send(client, &c, 1, 0); + while (read(cgi_output[0], &c, 1) > 0) send(client, &c, 1, 0); close(cgi_output[0]); close(cgi_input[1]);