mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-22 20:44:56 +00:00
add some mime types to the lame web server
This commit is contained in:
parent
a19c4f231f
commit
d9c98f3a73
@ -979,11 +979,23 @@ void ServiceConnection(AcceptedConnection *conn)
|
||||
std::vector<char> file_data;
|
||||
if( load_file(strURI.c_str(), file_data) == 0 ) {
|
||||
std::string str(file_data.data(), file_data.size());
|
||||
conn->stream() << HTTPReply(HTTP_OK, str, false, "text/html") << std::flush;
|
||||
const char *contentType = "text/html";
|
||||
if( strURI.find(".js") != std::string::npos )
|
||||
contentType = "text/javascript";
|
||||
if( strURI.find(".css") != std::string::npos )
|
||||
contentType = "text/css";
|
||||
if( strURI.find(".png") != std::string::npos )
|
||||
contentType = "image/png";
|
||||
if( strURI.find(".ttf") != std::string::npos )
|
||||
contentType = "application/x-font-ttf";
|
||||
if( strURI.find(".jpg") != std::string::npos ||
|
||||
strURI.find(".jpeg") != std::string::npos )
|
||||
contentType = "image/jpeg";
|
||||
conn->stream() << HTTPReply(HTTP_OK, str, false, contentType) << std::flush;
|
||||
} else {
|
||||
conn->stream() << HTTPReply(HTTP_NOT_FOUND, "", false) << std::flush;
|
||||
}
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check authorization
|
||||
|
Loading…
x
Reference in New Issue
Block a user