All responses with Location header are now 3xx redirects.

This commit is contained in:
Dorian Niemiec 2024-02-11 14:48:18 +01:00
parent 41a9052a07
commit fb9bb1e798

View file

@ -251,6 +251,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
else msg = http.STATUS_CODES[code]; else msg = http.STATUS_CODES[code];
} }
} }
var hasLocation = false;
for (var i = 0; i < bheaders.length; i++) { for (var i = 0; i < bheaders.length; i++) {
var headerp = bheaders[i].match(/^([^:]*)(?:: (.*))?/); var headerp = bheaders[i].match(/^([^:]*)(?:: (.*))?/);
if (!headerp) headerp = []; if (!headerp) headerp = [];
@ -267,11 +268,12 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
if (!bheaderso["Set-Cookie"]) bheaderso["Set-Cookie"] = []; if (!bheaderso["Set-Cookie"]) bheaderso["Set-Cookie"] = [];
bheaderso["Set-Cookie"].push(headerv); bheaderso["Set-Cookie"].push(headerv);
} else { } else {
if (headern.toLowerCase() == "location") hasLocation = true;
bheaderso[headern] = headerv; bheaderso[headern] = headerv;
} }
} }
if (code == 200 && (bheaderso["Location"] || bheaderso["location"])) { if (code < 300 && code > 399 && hasLocation) {
code = 302; code = 302;
msg = "Found"; msg = "Found";
} }