@nora-soderlund/http-early-hints
v1.0.2
Published
[](https://www.npmjs.com/package/@nora-soderlund/http-early-hints) [;
const http = require("http");
const httpServer = http.createServer();
const { httpWriteEarlyHints } = require("@nora-soderlund/http-early-hints");
httpServer.on("request", (request, response) => {
if(request.url == "/index.html") {
console.log(`103 Early Hints for ${request.url}`);
httpWriteEarlyHints(request, response, [
"</main.css>; rel=preload; as=style"
]);
// process the response
console.log(`200 OK for ${request.url}`);
// include the Link headers in the final header for backwards compability
response.writeHead(200, "OK", {
//"Content-Type": "text/html; charset=UTF-8",
"Link": hints
});
// response.end();
}
});
httpServer.listen(80);