allow static .json files being served by HTTP port

This commit is contained in:
john30
2015-06-06 09:01:53 +02:00
parent a287effde4
commit 6a9dafd897
2 changed files with 7 additions and 1 deletions
+1
View File
@@ -7,6 +7,7 @@
* new "read" option "-n" for retrieving name/value pairs in numeric form
* new "find" option "-e" for exactly matching name and optional circuit (ignoring case)
* added numeric and verbose options to JSON and use "null" for unset or replacement value
* allow static ".json" files being served by HTTP port
* allow passing raw value when writing name/value pairs
## Changed files
+6 -1
View File
@@ -966,7 +966,7 @@ string MainLoop::executeGet(vector<string> &args, bool& connected)
result << "HTTP/1.0 200 OK\r\n";
result << "Content-Type: application/json;charset=utf-8\r\n";
result << "Content-Length: " << setw(0) << dec << static_cast<unsigned>(str.length());
result << "\r\n\r\n";
result << "\r\nConnection: close\r\n\r\n";
result << str;
return result.str();
}
@@ -994,6 +994,8 @@ string MainLoop::executeGet(vector<string> &args, bool& connected)
type = 4;
} else if (ext == "svg") {
type = 5;
} else if (ext == "json") {
type = 6;
}
}
if (type < 0) {
@@ -1026,6 +1028,9 @@ string MainLoop::executeGet(vector<string> &args, bool& connected)
case 5:
result << "image/svg+xml";
break;
case 6:
result << "application/json;charset=utf-8";
break;
default:
result << "text/html";
break;