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