fix issue with large POSTs

This commit is contained in:
zefie
2025-08-08 11:32:22 -04:00
parent 932593aa21
commit afdade7d9c

View File

@@ -1358,7 +1358,7 @@ async function doHTTPProxy(socket, request_headers) {
errpage = wtvshared.doErrorPage(400, `The publisher <b>${request_data.host}</b> is unknown.`); errpage = wtvshared.doErrorPage(400, `The publisher <b>${request_data.host}</b> is unknown.`);
sendToClient(socket, errpage[0], errpage[1]); sendToClient(socket, errpage[0], errpage[1]);
} else { } else {
if (minisrv_config.services[request_type].external_proxy_is_http1 && !data_handled) { if (minisrv_config.services[request_type].external_proxy_is_http1) {
handleProxy(socket, request_type, request_headers, res, data); handleProxy(socket, request_type, request_headers, res, data);
} else { } else {
console.error(" * Unhandled Proxy Request Error:", err); console.error(" * Unhandled Proxy Request Error:", err);
@@ -1981,9 +1981,13 @@ async function processRequest(socket, data_hex, skipSecure = false, encryptedReq
if (socket_sessions[socket.id].secure) post_string = "Encrypted " + post_string; if (socket_sessions[socket.id].secure) post_string = "Encrypted " + post_string;
// the client may have just sent the data with the primary headers, so lets look for that. // the client may have just sent the data with the primary headers, so lets look for that.
if (data_hex.includes("0d0a0d0a")) socket_sessions[socket.id].post_data = data_hex.slice(data_hex.indexOf("0d0a0d0a") + 8); if (data_hex.includes("0d0a0d0a")) {
if (data_hex.includes("0a0d0a")) socket_sessions[socket.id].post_data = data_hex.slice(data_hex.indexOf("0a0d0a") + 6); socket_sessions[socket.id].post_data = data_hex.slice(data_hex.indexOf("0d0a0d0a") + 8);
if (data_hex.includes("0a0a")) socket_sessions[socket.id].post_data = data_hex.slice(data_hex.indexOf("0a0a") + 4); } else if (data_hex.includes("0a0d0a")) {
socket_sessions[socket.id].post_data = data_hex.slice(data_hex.indexOf("0a0d0a") + 6);
} else if (data_hex.includes("0a0a")) {
socket_sessions[socket.id].post_data = data_hex.slice(data_hex.indexOf("0a0a") + 4);
}
} }
if (socket_sessions[socket.id].post_data.length == (socket_sessions[socket.id].post_data_length * 2)) { if (socket_sessions[socket.id].post_data.length == (socket_sessions[socket.id].post_data_length * 2)) {
@@ -2005,8 +2009,6 @@ async function processRequest(socket, data_hex, skipSecure = false, encryptedReq
} else { } else {
// expecting more data (see below) // expecting more data (see below)
socket_sessions[socket.id].expecting_post_data = true; socket_sessions[socket.id].expecting_post_data = true;
if (!socket_sessions[socket.id].post_data) socket_sessions[socket.id].post_data = '';
socket_sessions[socket.id].post_data += CryptoJS.enc.Hex.parse(socket_sessions[socket.id].post_data);
console.log(" * Incoming", post_string, "request on", socket.id, "from", wtvshared.filterSSID(socket.ssid), "to", headers['request_url'], "(expecting", socket_sessions[socket.id].post_data_length, "bytes of data from client...)"); console.log(" * Incoming", post_string, "request on", socket.id, "from", wtvshared.filterSSID(socket.ssid), "to", headers['request_url'], "(expecting", socket_sessions[socket.id].post_data_length, "bytes of data from client...)");
} }
return; return;
@@ -2025,7 +2027,7 @@ async function processRequest(socket, data_hex, skipSecure = false, encryptedReq
} else if (socket.ssid) { } else if (socket.ssid) {
try { try {
// handle streaming POST // handle streaming POST
if (socket_sessions[socket.id].expecting_post_data && headers) { if (socket_sessions[socket.id].expecting_post_data) {
if (socket_sessions[socket.id].post_data_length > (minisrv_config.config.max_post_length * 1024 * 1024)) { if (socket_sessions[socket.id].post_data_length > (minisrv_config.config.max_post_length * 1024 * 1024)) {
closeSocket(socket); closeSocket(socket);
} else { } else {