diff --git a/src/URI.cpp b/src/URI.cpp index 0ec6573..0c6b465 100644 --- a/src/URI.cpp +++ b/src/URI.cpp @@ -59,6 +59,7 @@ URI::URI(string webroot, string reqpath) { } this->webroot = webroot; this->reqpath = reqpath; + this->info = ""; string abs = reqpath; if (fileExists(webroot + abs)) { @@ -140,7 +141,7 @@ FILE *URI::openFile() { } string URI::getFilePathInfo() { - return ""; //getAbsolutePath().erase(getFilePath().length(), getAbsolutePath().length()); + return info; //getAbsolutePath().erase(getFilePath().length(), getAbsolutePath().length()); } string URI::getFileType() { diff --git a/src/URI.h b/src/URI.h index 038a130..a56d129 100644 --- a/src/URI.h +++ b/src/URI.h @@ -12,6 +12,7 @@ private: string reqpath; string relpath; string query; + string info; string filepath; bool queryinit; diff --git a/src/client.cpp b/src/client.cpp index aede89b..33bc762 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -229,7 +229,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col } else if (etag) { req.respond(304); } else { - int statuscode = 200; + int statuscode = 0; if (!path.isStatic()) { string cmd = (string) "env -i" + " REDIRECT_STATUS=" + cli_encode("CGI") + @@ -282,19 +282,22 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col while (data[0] == ' ') data.erase(data.begin() + 0); while (data[data.length() - 1] == ' ') data.erase(data.end() - 1); - if (index == "Location") { - statuscode = 303; + if (index == "Status") { + statuscode = (int) strtol(data.substr(0, 3).c_str(), nullptr, 10); + } else { + if (index == "Location" && statuscode == 0) { + statuscode = 303; + } + req.setField(index, data); } - - req.setField(index, data); } fclose(file); file = pipes.stdout; - - } + statuscode = (statuscode == 0) ? 200 : statuscode; + bool compress = path.isStatic() && type.find("text/") == 0 && req.isExistingField("Accept-Encoding") && req.getField("Accept-Encoding").find("deflate") != string::npos;