MAJOR: Updates for Authenticated Web UI and CLI #30
|
@ -599,6 +599,7 @@ function handleApi(req, res) {
|
|||
));
|
||||
}
|
||||
|
||||
function route() {
|
||||
if (/\b(config)\b/.test(opts.pathname) && /get/i.test(req.method)) {
|
||||
getConfigOnly();
|
||||
return;
|
||||
|
@ -656,6 +657,32 @@ function handleApi(req, res) {
|
|||
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify({"error":{"message":"unrecognized rpc"}}));
|
||||
}
|
||||
|
||||
if (!req.headers['content-length'] && !req.headers['content-type']) {
|
||||
route();
|
||||
return;
|
||||
}
|
||||
|
||||
var body = '';
|
||||
req.on('readable', function () {
|
||||
var data;
|
||||
while (true) {
|
||||
data = req.read();
|
||||
if (!data) { break; }
|
||||
body += data.toString();
|
||||
}
|
||||
});
|
||||
req.on('end', function () {
|
||||
try {
|
||||
opts.body = JSON.parse(body);
|
||||
} catch(e) {
|
||||
res.statusCode = 400;
|
||||
res.end('{"error":{"message":"POST body is not valid json"}}');
|
||||
return;
|
||||
}
|
||||
route();
|
||||
});
|
||||
}
|
||||
function serveControlsHelper() {
|
||||
controlServer = http.createServer(handleRemoteClient);
|
||||
|
|
Loading…
Reference in New Issue