From 6a9dafd897e4001ee194ae0e49dbd18c508df6e1 Mon Sep 17 00:00:00 2001 From: john30 Date: Sat, 6 Jun 2015 09:01:53 +0200 Subject: [PATCH] allow static .json files being served by HTTP port --- ChangeLog.md | 1 + src/ebusd/mainloop.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index bcb4d2c6..125f8465 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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 diff --git a/src/ebusd/mainloop.cpp b/src/ebusd/mainloop.cpp index 0087c967..fbdf750c 100644 --- a/src/ebusd/mainloop.cpp +++ b/src/ebusd/mainloop.cpp @@ -966,7 +966,7 @@ string MainLoop::executeGet(vector &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(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 &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 &args, bool& connected) case 5: result << "image/svg+xml"; break; + case 6: + result << "application/json;charset=utf-8"; + break; default: result << "text/html"; break;