From 4856e4521b0084fa12886f300c9133920a09177f Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Mon, 30 Nov 2020 18:34:27 +0100 Subject: [PATCH] Debugging --- src/client.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/client.cpp b/src/client.cpp index d6c1e69..29bf970 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -223,6 +223,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col char *prefix = (char *) preprefix; HttpConnection *req = nullptr; + printf("STAGE 1"); try { *req = HttpConnection(socket); } catch (char *msg) { @@ -243,6 +244,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col } } + printf("STAGE 2"); try { bool noRedirect, redir, invalidMethod, etag; @@ -274,6 +276,8 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col host.erase(pos, host.length() - pos); } + printf("STAGE 3"); + /* FILE *name = popen(("dig @8.8.8.8 +time=1 -x " + socket->getPeerAddress()->toString() + " | grep -oP \"^[^;].*\\t\\K([^ ]*)\\w\"").c_str(), "r"); @@ -294,6 +298,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col log_to_file(prefix, "\x1B[1m" + req->getMethod() + " " + req->getPath() + "\x1B[0m", host); noRedirect = req->getPath().find("/.well-known/") == 0 || (req->getPath().find("/files/") == 0); + printf("STAGE 4"); redir = true; if (!noRedirect) { @@ -310,6 +315,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col *path = URI(getWebRoot(host), req->getPath()); childpid = 0; + printf("STAGE 5"); if (redir) { goto respond; @@ -330,6 +336,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col req->respond(403); goto respond; } + printf("STAGE 6"); req->setField("Content-Type", type); req->setField("Last-Modified", getHttpDate(path->getFilePath())); @@ -361,6 +368,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col invalidMethod = true; } } + printf("STAGE 7"); if (invalidMethod) { req->respond(405); @@ -401,6 +409,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col " GATEWAY_INTERFACE=" + cli_encode("CGI/1.1") + " /usr/bin/php-cgi"; + printf("STAGE 8"); stds pipes = procopen(cmd.c_str()); childpid = pipes.pid; @@ -412,6 +421,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col fclose(pipes.stdin); t = new thread(php_error_handler, prefix, pipes.stderr); + printf("STAGE 9"); string line; while (!(line = read_line(pipes.stdout)).empty()) { @@ -435,6 +445,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col req->setField(index, data); } } + printf("STAGE 10"); fclose(file); int c = fgetc(pipes.stdout); @@ -448,6 +459,8 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col file = pipes.stdout; } + printf("STAGE 11"); + if (statuscode != -1) { statuscode = (statuscode == 0) ? 200 : statuscode; @@ -500,12 +513,15 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col } } + printf("STAGE 12"); + fclose(file); if (childpid > 0) { waitpid(childpid, nullptr, 0); } respond: + printf("STAGE RESPOND"); HttpStatusCode status = req->getStatusCode(); int code = status.code;