catch request errors

This commit is contained in:
AJ ONeal 2019-06-30 18:07:13 -06:00
parent 778416d49b
commit 6cdbe36e6c
1 changed files with 28 additions and 18 deletions

View File

@ -53,9 +53,14 @@ module.exports.create = function(opts) {
console.warn("'" + p + "' doesn't seem to be a valid port number, socket path, or pipe");
}
server = require("http").createServer(
greenlock.middleware.sanitizeHost(greenlock.middleware(require("redirect-https")()))
);
var mw = greenlock.middleware.sanitizeHost(greenlock.middleware(require("redirect-https")()));
server = require("http").createServer(function(req, res) {
req.on("error", function(err) {
console.error("Insecure Request Network Connection Error:");
console.error(err);
});
mw(req, res);
});
httpType = "http";
return {
@ -208,9 +213,8 @@ module.exports.create = function(opts) {
);
}
}
server = https.createServer(
greenlock.tlsOptions,
greenlock.middleware.sanitizeHost(function(req, res) {
var mw = greenlock.middleware.sanitizeHost(function(req, res) {
try {
greenlock.app(req, res);
} catch (e) {
@ -224,8 +228,14 @@ module.exports.create = function(opts) {
// (headers may have already been sent, etc)
}
}
})
);
});
server = https.createServer(greenlock.tlsOptions, function(req, res) {
req.on("error", function(err) {
console.error("HTTPS Request Network Connection Error:");
console.error(err);
});
mw(req, res);
});
server.type = httpType;
return {