1
0
Fork 0
forked from svrjs/svrjs

Fix HTML MIME type in cached requests, regardless of the extension

This commit is contained in:
Dorian Niemiec 2024-08-27 09:27:35 +02:00
parent 33fde81ba1
commit 4eb2987f01
5 changed files with 11 additions and 11 deletions

View file

@ -7,13 +7,13 @@ const generateServerString = require("../utils/generateServerString.js");
let serverconsole = {};
function clientErrorHandler(err, socket) {
const config = Object.assign(process.serverConfig);
const config = Object.assign({}, process.serverConfig);
config.generateServerString = () =>
generateServerString(config.exposeServerVersion);
// getCustomHeaders() in SVR.JS 3.x
config.getCustomHeaders = () => Object.assign(config.customHeaders);
config.getCustomHeaders = () => Object.assign({}, config.customHeaders);
// Prevent multiple error handlers from one request
if (socket.__assigned__) {
@ -54,7 +54,7 @@ function clientErrorHandler(err, socket) {
if (code >= 400 && code <= 499) process.err4xxcounter++;
if (code >= 500 && code <= 599) process.err5xxcounter++;
let head = "HTTP/1.1 " + code.toString() + " " + name + "\r\n";
headers = Object.assign(headers);
headers = Object.assign({}, headers);
headers["Date"] = new Date().toGMTString();
headers["Connection"] = "close";
Object.keys(headers).forEach(function (headername) {

View file

@ -27,7 +27,7 @@ function noproxyHandler(req, socket, head) {
socket.on("error", () => {});
// SVR.JS configuration object (modified)
const config = Object.assign(process.serverConfig);
const config = Object.assign({}, process.serverConfig);
var reqip = socket.remoteAddress;
var reqport = socket.remotePort;

View file

@ -29,7 +29,7 @@ function proxyHandler(req, socket, head) {
socket.on("error", () => {});
// SVR.JS configuration object (modified)
const config = Object.assign(process.serverConfig);
const config = Object.assign({}, process.serverConfig);
config.generateServerString = () => {
return generateServerString(config.exposeServerVersion);

View file

@ -29,7 +29,7 @@ function requestHandler(req, res) {
};
// SVR.JS configuration object (modified)
const config = Object.assign(process.serverConfig);
const config = Object.assign({}, process.serverConfig);
config.generateServerString = () => {
return generateServerString(config.exposeServerVersion);
@ -37,7 +37,7 @@ function requestHandler(req, res) {
// getCustomHeaders() in SVR.JS 3.x
config.getCustomHeaders = () => {
let ph = Object.assign(config.customHeaders);
let ph = Object.assign({}, config.customHeaders);
if (config.customHeadersVHost) {
let vhostP = null;
config.customHeadersVHost.every(function (vhost) {
@ -52,7 +52,7 @@ function requestHandler(req, res) {
}
});
if (vhostP && vhostP.headers) {
const phNu = Object.assign(vhostP.headers);
const phNu = Object.assign({}, vhostP.headers);
Object.keys(phNu).forEach(function (phNuK) {
ph[phNuK] = phNu[phNuK];
});
@ -80,7 +80,7 @@ function requestHandler(req, res) {
if (typeof b == "object") table = b;
if (table == undefined) table = this.tHeaders;
if (table == undefined) table = {};
table = Object.assign(table);
table = Object.assign({}, table);
Object.keys(table).forEach(function (key) {
const al = key.toLowerCase();
if (

View file

@ -87,9 +87,9 @@ if (!process.singleThreaded) {
cluster.workers = {};
cluster.fork = function (env) {
const child_process = require("child_process");
let newEnvironment = Object.assign(env ? env : process.env);
let newEnvironment = Object.assign({}, env ? env : process.env);
newEnvironment.NODE_UNIQUE_ID = cluster._workersCounter;
let newArguments = Object.assign(process.argv);
let newArguments = Object.assign({}, process.argv);
let command = newArguments.shift();
let newWorker = child_process.spawn(command, newArguments, {
env: newEnvironment,