also serve .csv, fix for invalid HTTP requests
This commit is contained in:
@@ -480,6 +480,11 @@ result_t MainLoop::decodeMessage(const string &data, bool isHttp, bool* connecte
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isHttp) {
|
if (isHttp) {
|
||||||
|
if (args.size() < 2) {
|
||||||
|
*connected = false;
|
||||||
|
*ostream << "HTTP/1.0 400 Bad Request\r\n\r\n";
|
||||||
|
return RESULT_OK;
|
||||||
|
}
|
||||||
const char* str = args.size() > 0 ? args[0].c_str() : "";
|
const char* str = args.size() > 0 ? args[0].c_str() : "";
|
||||||
if (strcmp(str, "GET") == 0) {
|
if (strcmp(str, "GET") == 0) {
|
||||||
return executeGet(args, connected, ostream);
|
return executeGet(args, connected, ostream);
|
||||||
@@ -1794,6 +1799,8 @@ result_t MainLoop::executeGet(const vector<string>& args, bool* connected, ostri
|
|||||||
type = 6;
|
type = 6;
|
||||||
} else if (ext == "yaml") {
|
} else if (ext == "yaml") {
|
||||||
type = 7;
|
type = 7;
|
||||||
|
} else if (ext == "csv") {
|
||||||
|
type = 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type < 0) {
|
if (type < 0) {
|
||||||
@@ -1843,6 +1850,9 @@ result_t MainLoop::formatHttpResult(result_t ret, int type, ostringstream* ostre
|
|||||||
case 7:
|
case 7:
|
||||||
*ostream << "application/yaml;charset=utf-8";
|
*ostream << "application/yaml;charset=utf-8";
|
||||||
break;
|
break;
|
||||||
|
case 9:
|
||||||
|
*ostream << "text/comma-separated-values";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
*ostream << "text/html";
|
*ostream << "text/html";
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user