diff --git a/zefie_wtvp_minisrv/app.js b/zefie_wtvp_minisrv/app.js index 57cc7c1d..4b247f81 100644 --- a/zefie_wtvp_minisrv/app.js +++ b/zefie_wtvp_minisrv/app.js @@ -206,7 +206,7 @@ async function sendRawFile(socket, path) { const contypes = wtvmime.getContentType(path); let headers = "200 OK\n" headers += "Content-Type: " + contypes[0] + "\n"; - headers += "wtv-modern-content-type" + contypes[1]; + headers += "wtv-modern-content-type: " + contypes[1]; fs.readFile(path, null, function (err, data) { sendToClient(socket, headers, data); }); @@ -1415,7 +1415,7 @@ async function sendToClient(socket, headers_obj, data = null) { const eol = "\n"; let timezone = "-0000"; let wtv_connection_close = false; - +console.log(headers_obj) if (typeof (data) === 'undefined' || data === null) data = ''; if (typeof (headers_obj) === 'string') { // string to header object @@ -1475,6 +1475,7 @@ async function sendToClient(socket, headers_obj, data = null) { delete headers_obj[contype_key]; } } + // Add last modified if not a dynamic script if (socket_sessions[socket.id]) { @@ -1525,6 +1526,7 @@ async function sendToClient(socket, headers_obj, data = null) { } } } + console.log(compression_type) // webtvism if (headers_obj["minisrv-force-compression"]) { @@ -1532,6 +1534,10 @@ async function sendToClient(socket, headers_obj, data = null) { delete headers_obj["minisrv-force-compression"]; } + if (headers_obj["wtv-modern-content-type"]) { + delete headers_obj["wtv-modern-content-type"]; + } + if (socket.res) { // pc mode with response object available if (compression_type == 1) compression_type = 2; // wtv-lzpf not supported in pc mode } diff --git a/zefie_wtvp_minisrv/includes/classes/WTVMime.js b/zefie_wtvp_minisrv/includes/classes/WTVMime.js index b2649a57..da54b4d9 100644 --- a/zefie_wtvp_minisrv/includes/classes/WTVMime.js +++ b/zefie_wtvp_minisrv/includes/classes/WTVMime.js @@ -26,7 +26,7 @@ class WTVMime { let compression_type = 0; // no compression if (ssid_session) { if (ssid_session.capabilities) { - if (ssid_session.capabilities['client-can-receive-compressed-data']) { + if (ssid_session.capabilities.get('client-can-receive-compressed-data')) { if (this.minisrv_config.config.enable_lzpf_compression || this.minisrv_config.config.force_compression_type) { compression_type = 1; // lzpf @@ -61,7 +61,7 @@ class WTVMime { // should we bother to compress? let content_type = ""; if (typeof (headers_obj) == 'string') content_type = headers_obj; - else content_type = (typeof (headers_obj["wtv-modern-content-type"]) != 'undefined') ? headers_obj["wtv-modern-content-type"] : headers_obj["Content-type"]; + else content_type = (typeof (headers_obj["wtv-modern-content-type"]) !== 'undefined') ? headers_obj["wtv-modern-content-type"] : headers_obj["Content-type"]; if (content_type) { // both lzpf and gzip @@ -100,7 +100,7 @@ class WTVMime { */ getContentType(path) { const file_ext = this.wtvshared.getFileExt(path).toLowerCase(); - let wtv_mime_type, modern_mime_type = ""; + let wtv_mime_type, modern_mime_type; // process WebTV overrides, fall back to generic mime lookup switch (file_ext) { case "aif": @@ -192,7 +192,7 @@ class WTVMime { modern_mime_type = this.mime.lookup(path); if (modern_mime_type === false) modern_mime_type = "application/octet-stream"; - if (wtv_mime_type == "") wtv_mime_type = modern_mime_type; + if (typeof wtv_mime_type === 'undefined') wtv_mime_type = modern_mime_type; return new Array(wtv_mime_type, modern_mime_type); }