Debugging 2

This commit is contained in:
2020-11-30 18:36:30 +01:00
parent 4856e4521b
commit 5ab6fafce9

View File

@ -223,7 +223,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
char *prefix = (char *) preprefix; char *prefix = (char *) preprefix;
HttpConnection *req = nullptr; HttpConnection *req = nullptr;
printf("STAGE 1"); printf("STAGE 1\n");
try { try {
*req = HttpConnection(socket); *req = HttpConnection(socket);
} catch (char *msg) { } catch (char *msg) {
@ -244,7 +244,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
} }
} }
printf("STAGE 2"); printf("STAGE 2\n");
try { try {
bool noRedirect, redir, invalidMethod, etag; bool noRedirect, redir, invalidMethod, etag;
@ -276,7 +276,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
host.erase(pos, host.length() - pos); host.erase(pos, host.length() - pos);
} }
printf("STAGE 3"); printf("STAGE 3\n");
/* /*
FILE *name = popen(("dig @8.8.8.8 +time=1 -x " + socket->getPeerAddress()->toString() + FILE *name = popen(("dig @8.8.8.8 +time=1 -x " + socket->getPeerAddress()->toString() +
@ -298,7 +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); 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); noRedirect = req->getPath().find("/.well-known/") == 0 || (req->getPath().find("/files/") == 0);
printf("STAGE 4"); printf("STAGE 4\n");
redir = true; redir = true;
if (!noRedirect) { if (!noRedirect) {
@ -315,7 +315,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
*path = URI(getWebRoot(host), req->getPath()); *path = URI(getWebRoot(host), req->getPath());
childpid = 0; childpid = 0;
printf("STAGE 5"); printf("STAGE 5\n");
if (redir) { if (redir) {
goto respond; goto respond;
@ -336,7 +336,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
req->respond(403); req->respond(403);
goto respond; goto respond;
} }
printf("STAGE 6"); printf("STAGE 6\n");
req->setField("Content-Type", type); req->setField("Content-Type", type);
req->setField("Last-Modified", getHttpDate(path->getFilePath())); req->setField("Last-Modified", getHttpDate(path->getFilePath()));
@ -368,7 +368,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
invalidMethod = true; invalidMethod = true;
} }
} }
printf("STAGE 7"); printf("STAGE 7\n");
if (invalidMethod) { if (invalidMethod) {
req->respond(405); req->respond(405);
@ -409,7 +409,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
" GATEWAY_INTERFACE=" + cli_encode("CGI/1.1") + " GATEWAY_INTERFACE=" + cli_encode("CGI/1.1") +
" /usr/bin/php-cgi"; " /usr/bin/php-cgi";
printf("STAGE 8"); printf("STAGE 8\n");
stds pipes = procopen(cmd.c_str()); stds pipes = procopen(cmd.c_str());
childpid = pipes.pid; childpid = pipes.pid;
@ -421,7 +421,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
fclose(pipes.stdin); fclose(pipes.stdin);
t = new thread(php_error_handler, prefix, pipes.stderr); t = new thread(php_error_handler, prefix, pipes.stderr);
printf("STAGE 9"); printf("STAGE 9\n");
string line; string line;
while (!(line = read_line(pipes.stdout)).empty()) { while (!(line = read_line(pipes.stdout)).empty()) {
@ -445,7 +445,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
req->setField(index, data); req->setField(index, data);
} }
} }
printf("STAGE 10"); printf("STAGE 10\n");
fclose(file); fclose(file);
int c = fgetc(pipes.stdout); int c = fgetc(pipes.stdout);
@ -459,7 +459,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
file = pipes.stdout; file = pipes.stdout;
} }
printf("STAGE 11"); printf("STAGE 11\n");
if (statuscode != -1) { if (statuscode != -1) {
statuscode = (statuscode == 0) ? 200 : statuscode; statuscode = (statuscode == 0) ? 200 : statuscode;
@ -513,7 +513,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
} }
} }
printf("STAGE 12"); printf("STAGE 12\n");
fclose(file); fclose(file);
if (childpid > 0) { if (childpid > 0) {
@ -521,7 +521,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
} }
respond: respond:
printf("STAGE RESPOND"); printf("STAGE RESPOND\n");
HttpStatusCode status = req->getStatusCode(); HttpStatusCode status = req->getStatusCode();
int code = status.code; int code = status.code;