Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /usr/share/doc/node-negotiator/examples/ drwxr-xr-x | |
| Viewing file: Select action/file-type: (function() {
var Negotiator, availableMediaTypes, http, key, representations, server, val;
Negotiator = require('../lib/negotiator').Negotiator;
http = require('http');
representations = {
'text/html': '<h1>Hello world!</h1>',
'text/plain': 'Hello World!',
'application/json': JSON.stringify({
hello: 'world!'
})
};
availableMediaTypes = (function() {
var _results;
_results = [];
for (key in representations) {
val = representations[key];
_results.push(key);
}
return _results;
})();
server = http.createServer(function(req, res) {
var mediaType, negotiator;
negotiator = new Negotiator(req);
console.log("Accept: " + req.headers['accept']);
console.log("Preferred: " + (negotiator.mediaTypes()));
console.log("Possible: " + (negotiator.mediaTypes(availableMediaTypes)));
mediaType = negotiator.mediaType(availableMediaTypes);
console.log("Selected: " + mediaType);
if (mediaType) {
res.writeHead(200, {
'Content-Type': mediaType
});
return res.end(representations[mediaType]);
} else {
res.writeHead(406);
return res.end();
}
});
server.listen(8080);
}).call(this);
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0037 ]-- |