node-http-server – Diff between revs 35 and 36

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 35 Rev 36
Line 12... Line 12...
12 const url = require('url'); 12 const url = require('url');
13 const moment = require('moment'); 13 const moment = require('moment');
14 const winston = require('winston'); 14 const winston = require('winston');
15 const yargs = require('yargs'); 15 const yargs = require('yargs');
16 const dns = require('dns'); 16 const dns = require('dns');
-   17 const HttpCache = require("http-cache");
Line 17... Line 18...
17   18  
18 // Local imports. 19 // Local imports.
19 const Handler = require( 20 const Handler = require(
20 path 21 path
Line 88... Line 89...
88 if (error) { 89 if (error) {
89 log.error('Could not find document root: ' + argv.root); 90 log.error('Could not find document root: ' + argv.root);
90 process.exit(1); 91 process.exit(1);
91 } 92 }
Line -... Line 93...
-   93  
-   94 // Create server-side cache.
-   95 const httpcache = new HttpCache();
92   96  
93 // Start HTTP server. 97 // Start HTTP server.
94 http.createServer( 98 http.createServer(
95 // authentication, 99 // authentication,
-   100 (request, response) =>
96 (request, response) => 101 httpcache(request, response, () => {
97 new Handler().process(config, request, response, root) 102 new Handler().process(config, request, response, root)
98 .on('log', (data) => { 103 .on('log', (data) => {
99 log.log(data.severity, data.message); 104 log.log(data.severity, data.message);
100 }) 105 })
101 .on('data', (result) => { 106 .on('data', (result) => {
102 response.setHeader('Content-Type', result.type); 107 response.setHeader('Content-Type', result.type);
103 response.writeHead(result.status); 108 response.writeHead(result.status);
104 result.data 109 result.data
105 .on('readable', () => result.data.pipe(response)) 110 .on('readable', () => result.data.pipe(response))
-   111 .on('end', () => response.end());
106 .on('end', () => response.end()); 112 });
107 }) 113 })
108 ).listen(config.net.port, config.net.address, () => { 114 ).listen(config.net.port, config.net.address, () => {
109 log.info('HTTP Server accessible at: http://' + 115 log.info('HTTP Server accessible at: http://' +
110 config.net.address + 116 config.net.address +