-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathfavicon.ico.js
More file actions
30 lines (29 loc) · 985 Bytes
/
favicon.ico.js
File metadata and controls
30 lines (29 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"use strict";
var path = require('path'),
mime = require('mime'),
fs = require('fs');
var favicon = path.join( __dirname , "/../../static/img/favicon.ico" );
exports.execute = function(req, resp){
if( req.headers["if-modified-since"] ){
resp.writeHead(304, "Not Modified");
resp.end();
return;
}
fs.readFile(favicon, function (err, data){
if(err){
resp.writeHead(404, {"Content-Type": mime.get("html")});
resp.end("no favicon.ico");
}else{
var expires = new Date();
expires.setHours( expires.getHours() + 2 );
resp.writeHead(200, {
"Content-Type": mime.get("ico"),
"Content-Length": data.length,
"Cache-Control": "max-age=7200",
"Last-Modified": new Date( "2015/06/28" ).toGMTString(),
"Expires": expires.toGMTString()
});
resp.end(data);
}
});
};