hopefully fix POST for real

- main function still could use a rewrite
- more class branching and moving of functions
- Pass minisrv_config to classes
This commit is contained in:
zefie
2021-08-10 21:41:34 -04:00
parent 5d07f02490
commit 3dd6e51832
11 changed files with 211 additions and 102 deletions

View File

@@ -1,5 +1,5 @@
const WTVDownloadList = require("./WTVDownloadList.js");
var wtvdl = new WTVDownloadList(service_name);
var wtvdl = new WTVDownloadList(minisrv_config, service_name);
var force_update = (request_headers.query.force == "true") ? true : false;
if (request_headers['wtv-request-type'] == 'download') {
@@ -272,5 +272,5 @@ if (request_headers['wtv-request-type'] == 'download') {
var message = request_headers.query.message || "Retrieving files...";
var main_message = request_headers.query.main_message || "Your receiver is downloading files.";
headers = "200 OK\nContent-Type: text/html";
data = wtvdl.getSyncPage(minisrv_config, message, request_headers.query.group, request_headers.query.diskmap, main_message, message, force_update)
data = wtvdl.getSyncPage(message, request_headers.query.group, request_headers.query.diskmap, main_message, message, force_update)
}

View File

@@ -0,0 +1,57 @@
const WTVDownloadList = require("./WTVDownloadList.js");
var wtvdl = new WTVDownloadList(minisrv_config);
if (request_headers['wtv-request-type'] == 'download') {
console.log(request_headers.post_data.toString(CryptoJS.enc.Latin1));
wtvdl.reset();
var froot = "file://disk/Demo/";
var fget = [
"attract.mpg",
"can-you-hear.mpg",
"explore.mpg",
"hear.html",
"index.html",
"menu1.html",
"menu2.html",
"menu3.html",
"menu4.html",
"service.html",
"splash-mits.mpg",
"splash-phil.mpg",
"splash-sony.mpg",
"splash1.html",
"splash2.html",
"splash3.html",
"what-is-it.html",
"what-is-it.mpg",
"what-others.html",
"what-others.mpg",
"whats-in-it.html",
"whats-in-it.mpg",
"whats-in-it.mpg.old"
];
Object.keys(fget).forEach(function (k) {
wtvdl.putUserStore(froot + fget[k]);
});
headers = "200 OK\nContent-type: " + wtvdl.content_type;
data = wtvdl.getDownloadList();
console.log(data);
} else {
headers = "200 OK\nContent-type: text/html";
var success_url = new clientShowAlert({
'image': minisrv_config.config.service_logo,
'message': "Upload successful!",
'buttonlabel1': "Okay",
'buttonaction1': "client:goback",
'noback': true,
}).getURL();
var fail_url = new clientShowAlert({
'image': minisrv_config.config.service_logo,
'message': "Upload failed...",
'buttonlabel1': "Okay...",
'buttonaction1': "client:goback",
'noback': true,
}).getURL();
data = wtvdl.getSyncPage("Testing", "UploadTest", null, "Your receiver is uploading files.", "Sending files", null, success_url, fail_url, "wtv-disk:/uptest");
}

View File

@@ -0,0 +1,23 @@
// todo some fancy ass file manager or something
if (socket.ssid) {
if (ssid_sessions[socket.ssid]) {
if (ssid_sessions[socket.ssid].isRegistered()) {
data = ssid_sessions[socket.ssid].getUserStoreFileByURL("file://Disk/Demo/allyouneed.html");
//data = ssid_sessions[socket.ssid].getUserStoreFile("Disk/Demo/allyouneed.html");
var contype = ssid_sessions[socket.ssid].getUserStoreContentType("file://Disk/Demo/allyouneed.html");
if (data) {
headers = "200 OK\n";
headers += "Content-Type: " + contype;
}
}
}
}
if (!headers) {
var errpage = doErrorPage(400)
headers = errpage[0];
data = errpage[1];
}

View File

@@ -7,7 +7,7 @@ Content-type: text/html`
if (request_headers.query.url) headers += "\nwtv-visit: " + request_headers.query.url;
var cryptstatus = ((socket_sessions[socket.id].secure === true) ? "Encrypted" : "Not Encrypted")
var comp_type = shouldWeCompress(socket.ssid,'text/html');
var comp_type = wtvmime.shouldWeCompress(ssid_sessions[socket.ssid],'text/html');
var compstatus = "uncompressed";
switch (comp_type) {
case 1: