Debugging
This commit is contained in:
@ -223,6 +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");
|
||||||
try {
|
try {
|
||||||
*req = HttpConnection(socket);
|
*req = HttpConnection(socket);
|
||||||
} catch (char *msg) {
|
} catch (char *msg) {
|
||||||
@ -243,6 +244,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf("STAGE 2");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
bool noRedirect, redir, invalidMethod, etag;
|
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);
|
host.erase(pos, host.length() - pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("STAGE 3");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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() +
|
||||||
" | grep -oP \"^[^;].*\\t\\K([^ ]*)\\w\"").c_str(), "r");
|
" | 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);
|
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");
|
||||||
|
|
||||||
redir = true;
|
redir = true;
|
||||||
if (!noRedirect) {
|
if (!noRedirect) {
|
||||||
@ -310,6 +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");
|
||||||
|
|
||||||
if (redir) {
|
if (redir) {
|
||||||
goto respond;
|
goto respond;
|
||||||
@ -330,6 +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");
|
||||||
|
|
||||||
req->setField("Content-Type", type);
|
req->setField("Content-Type", type);
|
||||||
req->setField("Last-Modified", getHttpDate(path->getFilePath()));
|
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;
|
invalidMethod = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf("STAGE 7");
|
||||||
|
|
||||||
if (invalidMethod) {
|
if (invalidMethod) {
|
||||||
req->respond(405);
|
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") +
|
" GATEWAY_INTERFACE=" + cli_encode("CGI/1.1") +
|
||||||
" /usr/bin/php-cgi";
|
" /usr/bin/php-cgi";
|
||||||
|
|
||||||
|
printf("STAGE 8");
|
||||||
stds pipes = procopen(cmd.c_str());
|
stds pipes = procopen(cmd.c_str());
|
||||||
childpid = pipes.pid;
|
childpid = pipes.pid;
|
||||||
|
|
||||||
@ -412,6 +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");
|
||||||
|
|
||||||
string line;
|
string line;
|
||||||
while (!(line = read_line(pipes.stdout)).empty()) {
|
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);
|
req->setField(index, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf("STAGE 10");
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
int c = fgetc(pipes.stdout);
|
int c = fgetc(pipes.stdout);
|
||||||
@ -448,6 +459,8 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
|
|||||||
file = pipes.stdout;
|
file = pipes.stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("STAGE 11");
|
||||||
|
|
||||||
if (statuscode != -1) {
|
if (statuscode != -1) {
|
||||||
statuscode = (statuscode == 0) ? 200 : statuscode;
|
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);
|
fclose(file);
|
||||||
if (childpid > 0) {
|
if (childpid > 0) {
|
||||||
waitpid(childpid, nullptr, 0);
|
waitpid(childpid, nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
respond:
|
respond:
|
||||||
|
printf("STAGE RESPOND");
|
||||||
|
|
||||||
HttpStatusCode status = req->getStatusCode();
|
HttpStatusCode status = req->getStatusCode();
|
||||||
int code = status.code;
|
int code = status.code;
|
||||||
|
Reference in New Issue
Block a user