23 if (!content.check(
"main.css")) {
24 if (!options.check(
"web")) {
25 content.put(
"main.css",
"\n\
31 font-family: verdana, arial, sans-serif;\n\
36 padding-bottom: 10px;\n\
40 text-decoration: none;\n\
44 text-decoration: none;\n\
48 text-decoration: none;\n\
51 mime.put(
"main.css",
"text/css");
59 std::string uri = cmd.
check(
"REQUEST_URI",
Value(
"")).toString();
60 if (uri.length()>=4) { uri = uri.substr(4); }
else { uri =
""; }
61 std::string fileName = uri;
63 if ((!content.check(uri))||options.check(
"no-web-cache")) {
64 if (options.check(
"web")) {
67 for (
size_t i=0; i<fileName.length(); i++) {
68 char ch = fileName[i];
69 if (ch ==
'.' && !first) {
72 if (ch ==
'/') { first =
true;
continue; }
74 if (ch >=
'a' && ch <=
'z') {
77 if (ch >=
'A' && ch <=
'Z') {
80 if (ch >=
'0' && ch <=
'9') {
83 if (ch ==
'-' || ch ==
'_') {
86 ((
char*)fileName.c_str())[i] =
'_';
89 fileName =
"index.html";
91 fileName = options.find(
"web").asString() +
"/" + fileName;
93 FILE *fin = fopen(fileName.c_str(),
"rb");
97 len = fread(buf,1,
sizeof(buf),fin);
99 accum += std::string(buf,len);
105 content.put(uri,accum);
106 if (uri.find(
".css")!=std::string::npos) {
107 mime.put(uri,
"text/css");
108 }
else if (uri.find(
".png")!=std::string::npos) {
109 mime.put(uri,
"image/png");
110 }
else if (uri.find(
".jpg")!=std::string::npos) {
111 mime.put(uri,
"image/jpeg");
112 }
else if (uri.find(
".js")!=std::string::npos) {
113 mime.put(uri,
"text/javascript");
115 mime.put(uri,
"text/html");
120 if (content.check(uri)) {
121 std::string txt = content.find(uri).asString();
122 std::string txtMime = mime.find(uri).asString();
123 printf(
" * %s %s %d bytes, %s\n",
125 (fileName!=uri)?fileName.c_str():
"",
132 printf(
" * %s - Unknown\n", cmd.
toString().c_str());
A simple collection of objects that can be described and transmitted in a portable way.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
A single value (typically within a Bottle).
virtual std::string asString() const
Get string value.
An interface to the operating system, including Port based communication.