Refactored client.cpp
This commit is contained in:
@ -245,7 +245,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
bool noRedirect, redir, invalidMethod, etag;
|
bool noRedirect, redir, invalidMethod, etag, compress;
|
||||||
URI path;
|
URI path;
|
||||||
pid_t childpid;
|
pid_t childpid;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
@ -436,21 +436,20 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
|
|||||||
}
|
}
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
file = pipes.stdout;
|
||||||
int c = fgetc(pipes.stdout);
|
int c = fgetc(pipes.stdout);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
// No Data -> Error
|
// No Data -> Error
|
||||||
req.respond((statuscode == 0) ? 500 : statuscode);
|
req.respond((statuscode == 0) ? 500 : statuscode);
|
||||||
statuscode = -1;
|
goto respond;
|
||||||
} else {
|
} else {
|
||||||
ungetc(c, pipes.stdout);
|
ungetc(c, pipes.stdout);
|
||||||
}
|
}
|
||||||
file = pipes.stdout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statuscode != -1) {
|
|
||||||
statuscode = (statuscode == 0) ? 200 : statuscode;
|
statuscode = (statuscode == 0) ? 200 : statuscode;
|
||||||
|
|
||||||
bool compress = (type.find("text/") == 0 ||
|
compress = (type.find("text/") == 0 ||
|
||||||
(type.find("application/") == 0 && type.find("+xml") != string::npos) ||
|
(type.find("application/") == 0 && type.find("+xml") != string::npos) ||
|
||||||
type == "application/json" ||
|
type == "application/json" ||
|
||||||
type == "application/javascript") &&
|
type == "application/javascript") &&
|
||||||
@ -497,7 +496,6 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
|
|||||||
} else {
|
} else {
|
||||||
req.respond(statuscode, file, compress);
|
req.respond(statuscode, file, compress);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
if (childpid > 0) {
|
if (childpid > 0) {
|
||||||
@ -508,8 +506,8 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
|
|||||||
|
|
||||||
HttpStatusCode status = req.getStatusCode();
|
HttpStatusCode status = req.getStatusCode();
|
||||||
int code = status.code;
|
int code = status.code;
|
||||||
string color = "";
|
string color;
|
||||||
string comment = "";
|
string comment;
|
||||||
if ((code >= 200 && code < 300) || code == 304) {
|
if ((code >= 200 && code < 300) || code == 304) {
|
||||||
color = "\x1B[1;32m"; // Success (Cached): Green
|
color = "\x1B[1;32m"; // Success (Cached): Green
|
||||||
} else if (code >= 100 && code < 200) {
|
} else if (code >= 100 && code < 200) {
|
||||||
|
Reference in New Issue
Block a user