|
@ -39,8 +39,7 @@ listen_t get_listen_t(string listen) { |
|
|
return ret; |
|
|
return ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
string getMime(string path) |
|
|
string getMime(string path) { |
|
|
{ |
|
|
|
|
|
string extension; |
|
|
string extension; |
|
|
size_t pos = path.rfind('.'); |
|
|
size_t pos = path.rfind('.'); |
|
|
extension = (pos == string::npos) ? "txt" : path.substr(pos + 1); |
|
|
extension = (pos == string::npos) ? "txt" : path.substr(pos + 1); |
|
@ -92,7 +91,8 @@ string getMime(string path) |
|
|
return ("font/woff"); |
|
|
return ("font/woff"); |
|
|
else if ((extension == "woff2")) |
|
|
else if ((extension == "woff2")) |
|
|
return ("font/woff2"); |
|
|
return ("font/woff2"); |
|
|
else if ((extension == "jar") || (extension == "war") || (extension == "ear")) |
|
|
else if ((extension == "jar") || (extension == "war") || |
|
|
|
|
|
(extension == "ear")) |
|
|
return ("application/java-archive"); |
|
|
return ("application/java-archive"); |
|
|
else if ((extension == "json")) |
|
|
else if ((extension == "json")) |
|
|
return ("application/json"); |
|
|
return ("application/json"); |
|
@ -108,7 +108,10 @@ string getMime(string path) |
|
|
return ("application/rtf"); |
|
|
return ("application/rtf"); |
|
|
else if ((extension == "m3u8")) |
|
|
else if ((extension == "m3u8")) |
|
|
return ("application/vnd.apple.mpegurl"); |
|
|
return ("application/vnd.apple.mpegurl"); |
|
|
else if ((extension == "xls") || (extension == "xlt") || (extension == "xlm") || (extension == "xld") || (extension == "xla") || (extension == "xlc") || (extension == "xlw") || (extension == "xll")) |
|
|
else if ((extension == "xls") || (extension == "xlt") || |
|
|
|
|
|
(extension == "xlm") || (extension == "xld") || |
|
|
|
|
|
(extension == "xla") || (extension == "xlc") || |
|
|
|
|
|
(extension == "xlw") || (extension == "xll")) |
|
|
return ("application/vnd.ms-excel"); |
|
|
return ("application/vnd.ms-excel"); |
|
|
else if ((extension == "ppt") || (extension == "pps")) |
|
|
else if ((extension == "ppt") || (extension == "pps")) |
|
|
return ("application/vnd.ms-powerpoint"); |
|
|
return ("application/vnd.ms-powerpoint"); |
|
@ -130,7 +133,8 @@ string getMime(string path) |
|
|
return ("application/x-makeself"); |
|
|
return ("application/x-makeself"); |
|
|
else if ((extension == "pl") || (extension == "pm")) |
|
|
else if ((extension == "pl") || (extension == "pm")) |
|
|
return ("application/x-perl"); |
|
|
return ("application/x-perl"); |
|
|
else if ((extension == "pdb") || (extension == "pqr") || (extension == "prc") || (extension == "pde")) |
|
|
else if ((extension == "pdb") || (extension == "pqr") || |
|
|
|
|
|
(extension == "prc") || (extension == "pde")) |
|
|
return ("application/x-pilot"); |
|
|
return ("application/x-pilot"); |
|
|
else if ((extension == "rar")) |
|
|
else if ((extension == "rar")) |
|
|
return ("application/x-rar-compressed"); |
|
|
return ("application/x-rar-compressed"); |
|
@ -144,7 +148,8 @@ string getMime(string path) |
|
|
return ("application/x-stuffit"); |
|
|
return ("application/x-stuffit"); |
|
|
else if ((extension == "tcl") || (extension == "tk")) |
|
|
else if ((extension == "tcl") || (extension == "tk")) |
|
|
return ("application/x-tcl"); |
|
|
return ("application/x-tcl"); |
|
|
else if ((extension == "der") || (extension == "pem") || (extension == "crt")) |
|
|
else if ((extension == "der") || (extension == "pem") || |
|
|
|
|
|
(extension == "crt")) |
|
|
return ("application/x-x509-ca-cert"); |
|
|
return ("application/x-x509-ca-cert"); |
|
|
else if ((extension == "xpi")) |
|
|
else if ((extension == "xpi")) |
|
|
return ("application/x-xpinstall"); |
|
|
return ("application/x-xpinstall"); |
|
@ -152,7 +157,8 @@ string getMime(string path) |
|
|
return ("application/xhtml+xml"); |
|
|
return ("application/xhtml+xml"); |
|
|
else if ((extension == "zip")) |
|
|
else if ((extension == "zip")) |
|
|
return ("application/zip"); |
|
|
return ("application/zip"); |
|
|
else if ((extension == "bin") || (extension == "exe") || (extension == "dll")) |
|
|
else if ((extension == "bin") || (extension == "exe") || |
|
|
|
|
|
(extension == "dll")) |
|
|
return ("application/octet-stream"); |
|
|
return ("application/octet-stream"); |
|
|
else if ((extension == "deb")) |
|
|
else if ((extension == "deb")) |
|
|
return ("application/octet-stream"); |
|
|
return ("application/octet-stream"); |
|
@ -162,9 +168,11 @@ string getMime(string path) |
|
|
return ("application/octet-stream"); |
|
|
return ("application/octet-stream"); |
|
|
else if ((extension == "img") || (extension == "iso")) |
|
|
else if ((extension == "img") || (extension == "iso")) |
|
|
return ("application/octet-stream"); |
|
|
return ("application/octet-stream"); |
|
|
else if ((extension == "msi") || (extension == "msp") || (extension == "msm")) |
|
|
else if ((extension == "msi") || (extension == "msp") || |
|
|
|
|
|
(extension == "msm")) |
|
|
return ("application/octet-stream"); |
|
|
return ("application/octet-stream"); |
|
|
else if ((extension == "mid") || (extension == "midi") || (extension == "kar")) |
|
|
else if ((extension == "mid") || (extension == "midi") || |
|
|
|
|
|
(extension == "kar")) |
|
|
return ("audio/midi"); |
|
|
return ("audio/midi"); |
|
|
else if ((extension == "mp3")) |
|
|
else if ((extension == "mp3")) |
|
|
return ("audio/mpeg"); |
|
|
return ("audio/mpeg"); |
|
@ -208,8 +216,8 @@ string read_file(string path) { |
|
|
std::stringstream ret; |
|
|
std::stringstream ret; |
|
|
struct stat info; |
|
|
struct stat info; |
|
|
if (stat(path.c_str(), &info) != 0 || S_ISDIR(info.st_mode)) { |
|
|
if (stat(path.c_str(), &info) != 0 || S_ISDIR(info.st_mode)) { |
|
|
std::cerr << "stat() error on " << path << ": " |
|
|
std::cerr << "stat() error on " << path << ": " << strerror(errno) |
|
|
<< strerror(errno) << "\n"; |
|
|
<< "\n"; |
|
|
return ""; |
|
|
return ""; |
|
|
} |
|
|
} |
|
|
std::ifstream file(path.c_str()); |
|
|
std::ifstream file(path.c_str()); |
|
|