-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
If I send a request without a Host header attached, the whole server crashes.
var hostParts = host.split(":", 2);
^
TypeError: Cannot read property 'split' of undefined
at createLocation (node_modules/mach/lib/utils/createConnection.js:47:23)
It looks like I'm behind a proxy that probes the host with host-less requests before sending the actual request.
I don't know HTTP well enough to know what the behavior should be if Host is unspecified. Maybe it should serve from the default hostname or maybe it should respond with a blank page and/or error code, but it certainly shouldn't crash the server.
Here's the test I used to see what the client was sending:
var http = require("http");
var server = http.createServer(
function (req, res) {
console.log(JSON.stringify(req.headers));
res.end();
}
);
server.listen(8080);
and the result:
{
"x-proxy-stuff": "…",
"x-proxy-stuff": "…",
"x-proxy-stuff": "…",
"x-proxy-stuff": "…"
}
{
"x-proxy-stuff": "…",
"x-proxy-stuff": "…",
"x-proxy-stuff": "…",
"x-proxy-stuff": "…"
}
{
"host": "x.x.x.x:8080",
"scheme": "http",
"cache-control": "max-age=0",
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"upgrade-insecure-requests": "1",
"user-agent": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.48 Mobile Safari/537.36",
"accept-encoding": "gzip, deflate, sdch",
"accept-language": "en-US,en;q=0.8",
"cookie": "…",
"x-proxy-stuff": "…",
"x-proxy-stuff": "…",
"x-proxy-stuff": "…",
"x-proxy-stuff": "…",
"x-proxy-stuff": "…",
"x-proxy-stuff": "…",
"connection": "Keep-Alive",
"x-proxy-stuff": "…",
"x-proxy-stuff": "…"
}
Metadata
Metadata
Assignees
Labels
No labels