rlgwebd.js: improve MIME types.
Respond with the proper MIME type for JSON, and identify HTML as using the UTF-8 charset.
This commit is contained in:
parent
6b209976d6
commit
37e6447094
1 changed files with 6 additions and 6 deletions
12
rlgwebd.js
12
rlgwebd.js
|
|
@ -352,7 +352,7 @@ function login(req, res, formdata) {
|
||||||
/* Technically there's a race condition for the "lock"file, but since
|
/* Technically there's a race condition for the "lock"file, but since
|
||||||
* it requires the user deliberately starting two games at similar times,
|
* it requires the user deliberately starting two games at similar times,
|
||||||
* it's not too serious. We can't get O_EXCL in Node anyway. */
|
* it's not too serious. We can't get O_EXCL in Node anyway. */
|
||||||
res.writeHead(200, {'Content-Type': 'text/plain'});
|
res.writeHead(200, {'Content-Type': 'application/json'});
|
||||||
var reply = {"t": "l", "id": nsession.sessid, "w": nsession.w, "h":
|
var reply = {"t": "l", "id": nsession.sessid, "w": nsession.w, "h":
|
||||||
nsession.h};
|
nsession.h};
|
||||||
res.write(JSON.stringify(reply));
|
res.write(JSON.stringify(reply));
|
||||||
|
|
@ -445,7 +445,7 @@ function register(req, res, formdata) {
|
||||||
tslog("sqlickrypt register failed with code %d", code);
|
tslog("sqlickrypt register failed with code %d", code);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res.writeHead(200, {'Content-Type': 'text/plain'});
|
res.writeHead(200, {'Content-Type': 'application/json'});
|
||||||
var reply = {"t": "r", "d": uname};
|
var reply = {"t": "r", "d": uname};
|
||||||
res.write(JSON.stringify(reply));
|
res.write(JSON.stringify(reply));
|
||||||
res.end();
|
res.end();
|
||||||
|
|
@ -465,7 +465,7 @@ function logout(term, res) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
term.close();
|
term.close();
|
||||||
var resheaders = {'Content-Type': 'text/plain'};
|
var resheaders = {'Content-Type': 'application/json'};
|
||||||
res.writeHead(200, resheaders);
|
res.writeHead(200, resheaders);
|
||||||
res.write(JSON.stringify({"t": "q"}));
|
res.write(JSON.stringify({"t": "q"}));
|
||||||
res.end();
|
res.end();
|
||||||
|
|
@ -495,7 +495,7 @@ function serveStatic(req, res, fname) {
|
||||||
path.exists(realname, function (exists) {
|
path.exists(realname, function (exists) {
|
||||||
var resheaders = {};
|
var resheaders = {};
|
||||||
if (!exists || !extension || extension == ".html")
|
if (!exists || !extension || extension == ".html")
|
||||||
resheaders["Content-Type"] = "text/html";
|
resheaders["Content-Type"] = "text/html; charset=utf-8";
|
||||||
else if (extension == ".png")
|
else if (extension == ".png")
|
||||||
resheaders["Content-Type"] = "image/png";
|
resheaders["Content-Type"] = "image/png";
|
||||||
else if (extension == ".css")
|
else if (extension == ".css")
|
||||||
|
|
@ -549,7 +549,7 @@ function readFeed(res, term) {
|
||||||
reply.n = term.nsend++;
|
reply.n = term.nsend++;
|
||||||
reply.d = result.toString("hex");
|
reply.d = result.toString("hex");
|
||||||
}
|
}
|
||||||
res.writeHead(200, { "Content-Type": "text/plain" });
|
res.writeHead(200, { "Content-Type": "application/json" });
|
||||||
res.write(JSON.stringify(reply));
|
res.write(JSON.stringify(reply));
|
||||||
res.end();
|
res.end();
|
||||||
}
|
}
|
||||||
|
|
@ -563,7 +563,7 @@ var errorcodes = [ "Generic Error", "Not logged in", "Invalid data",
|
||||||
"Server shutting down" ];
|
"Server shutting down" ];
|
||||||
|
|
||||||
function sendError(res, ecode, msg) {
|
function sendError(res, ecode, msg) {
|
||||||
res.writeHead(200, { "Content-Type": "text/plain" });
|
res.writeHead(200, { "Content-Type": "application/json" });
|
||||||
var edict = {"t": "E"};
|
var edict = {"t": "E"};
|
||||||
if (!(ecode < errorcodes.length && ecode > 0))
|
if (!(ecode < errorcodes.length && ecode > 0))
|
||||||
ecode = 0;
|
ecode = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue