Use uncompressed length for Content-length like WNI (fixes HTML pages)
This commit is contained in:
@@ -497,6 +497,7 @@ function headerStringToObj(headers, response = false) {
|
|||||||
|
|
||||||
async function sendToClient(socket, headers_obj, data) {
|
async function sendToClient(socket, headers_obj, data) {
|
||||||
var headers = "";
|
var headers = "";
|
||||||
|
var content_length = 0;
|
||||||
if (typeof (data) === 'undefined') data = '';
|
if (typeof (data) === 'undefined') data = '';
|
||||||
if (typeof (headers_obj) === 'string') {
|
if (typeof (headers_obj) === 'string') {
|
||||||
// string to header object
|
// string to header object
|
||||||
@@ -538,6 +539,8 @@ async function sendToClient(socket, headers_obj, data) {
|
|||||||
|
|
||||||
// compress if needed
|
// compress if needed
|
||||||
if (compress_data && clen > 0) {
|
if (compress_data && clen > 0) {
|
||||||
|
content_length = clen;
|
||||||
|
|
||||||
headers_obj["wtv-lzpf"] = 0;
|
headers_obj["wtv-lzpf"] = 0;
|
||||||
|
|
||||||
var wtvcomp = new WTVLzpf();
|
var wtvcomp = new WTVLzpf();
|
||||||
@@ -562,14 +565,16 @@ async function sendToClient(socket, headers_obj, data) {
|
|||||||
if (headers_obj["Content-Length"]) delete headers_obj["Content-Length"];
|
if (headers_obj["Content-Length"]) delete headers_obj["Content-Length"];
|
||||||
if (headers_obj["Content-length"]) delete headers_obj["Content-length"];
|
if (headers_obj["Content-length"]) delete headers_obj["Content-length"];
|
||||||
|
|
||||||
// On the WNI server this is the length before compression but we're using the length after compression.
|
if (content_length == 0) {
|
||||||
// It matches the HTTP spec anyway so leaving.
|
if (typeof data.length !== 'undefined') {
|
||||||
if (typeof data.length !== 'undefined') {
|
content_length = data.length;
|
||||||
headers_obj["Content-length"] = data.length;
|
} else if (typeof data.byteLength !== 'undefined') {
|
||||||
} else if (typeof data.byteLength !== 'undefined') {
|
content_length = data.byteLength;
|
||||||
headers_obj["Content-length"] = data.byteLength;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
headers_obj["Content-length"] = content_length;
|
||||||
|
|
||||||
if (ssid_sessions[socket.ssid]) {
|
if (ssid_sessions[socket.ssid]) {
|
||||||
if (ssid_sessions[socket.ssid].data_store.wtvsec_login) {
|
if (ssid_sessions[socket.ssid].data_store.wtvsec_login) {
|
||||||
if (ssid_sessions[socket.ssid].data_store.wtvsec_login.ticket_b64) {
|
if (ssid_sessions[socket.ssid].data_store.wtvsec_login.ticket_b64) {
|
||||||
|
|||||||
Reference in New Issue
Block a user