24 if (!content.check(
"main.css")) {
25 if (!options.check(
"web")) {
26 content.put(
"main.css",
"\n\
32 font-family: verdana, arial, sans-serif;\n\
37 padding-bottom: 10px;\n\
41 text-decoration: none;\n\
45 text-decoration: none;\n\
49 text-decoration: none;\n\
52 mime.put(
"main.css",
"text/css");
60 std::string uri = cmd.
check(
"REQUEST_URI",
Value(
"")).toString();
61 if (uri.length()>=4) { uri = uri.substr(4); }
else { uri =
""; }
62 std::string fileName = uri;
64 if ((!content.check(uri))||options.check(
"no-web-cache")) {
65 if (options.check(
"web")) {
68 for (
size_t i=0; i<fileName.length(); i++) {
69 char ch = fileName[i];
70 if (ch ==
'.' && !first)
continue;
71 if (ch ==
'/') { first =
true;
continue; }
73 if (ch>=
'a'&&ch<=
'z')
continue;
74 if (ch>=
'A'&&ch<=
'Z')
continue;
75 if (ch>=
'0'&&ch<=
'9')
continue;
76 if (ch ==
'-' || ch ==
'_')
continue;
77 ((
char*)fileName.c_str())[i] =
'_';
80 fileName =
"index.html";
82 fileName = options.find(
"web").asString() +
"/" + fileName;
84 FILE *fin = fopen(fileName.c_str(),
"rb");
88 len = fread(buf,1,
sizeof(buf),fin);
90 accum += std::string(buf,len);
96 content.put(uri,accum);
97 if (uri.find(
".css")!=std::string::npos) {
98 mime.put(uri,
"text/css");
99 }
else if (uri.find(
".png")!=std::string::npos) {
100 mime.put(uri,
"image/png");
101 }
else if (uri.find(
".jpg")!=std::string::npos) {
102 mime.put(uri,
"image/jpeg");
103 }
else if (uri.find(
".js")!=std::string::npos) {
104 mime.put(uri,
"text/javascript");
106 mime.put(uri,
"text/html");
111 if (content.check(uri)) {
112 std::string txt = content.find(uri).asString();
113 std::string txtMime = mime.find(uri).asString();
114 printf(
" * %s %s %d bytes, %s\n",
116 (fileName!=uri)?fileName.c_str():
"",
123 printf(
" * %s - Unknown\n", cmd.
toString().c_str());