|
|
@ -979,11 +979,23 @@ void ServiceConnection(AcceptedConnection *conn) |
|
|
|
std::vector<char> file_data; |
|
|
|
std::vector<char> file_data; |
|
|
|
if( load_file(strURI.c_str(), file_data) == 0 ) { |
|
|
|
if( load_file(strURI.c_str(), file_data) == 0 ) { |
|
|
|
std::string str(file_data.data(), file_data.size()); |
|
|
|
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 { |
|
|
|
} else { |
|
|
|
conn->stream() << HTTPReply(HTTP_NOT_FOUND, "", false) << std::flush; |
|
|
|
conn->stream() << HTTPReply(HTTP_NOT_FOUND, "", false) << std::flush; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Check authorization
|
|
|
|
// Check authorization
|
|
|
|