зеркало из https://github.com/mozilla/http-server.git
Merge pull request #293 from SteveVanOpstal/master
Add ecstatic's gzip mode
This commit is contained in:
Коммит
fed98f2dbb
|
@ -44,6 +44,8 @@ This will install `http-server` globally so that it may be run from the command
|
|||
|
||||
`-i` Display autoIndex (defaults to 'True')
|
||||
|
||||
`-g` or `--gzip` When enabled (defaults to 'False') it will serve `./public/some-file.js.gz` in place of `./public/some-file.js` when a gzipped version of the file exists and the request accepts gzip encoding.
|
||||
|
||||
`-e` or `--ext` Default file extension if none supplied (defaults to 'html')
|
||||
|
||||
`-s` or `--silent` Suppress log messages from output
|
||||
|
|
|
@ -22,6 +22,7 @@ if (argv.h || argv.help) {
|
|||
' -a Address to use [0.0.0.0]',
|
||||
' -d Show directory listings [true]',
|
||||
' -i Display autoIndex [true]',
|
||||
' -g --gzip Serve gzip files when possible [false]',
|
||||
' -e --ext Default file extension if none supplied [none]',
|
||||
' -s --silent Suppress log messages from output',
|
||||
' --cors[=headers] Enable CORS via the "Access-Control-Allow-Origin" header',
|
||||
|
@ -96,6 +97,7 @@ function listen(port) {
|
|||
cache: argv.c,
|
||||
showDir: argv.d,
|
||||
autoIndex: argv.i,
|
||||
gzip: argv.g || argv.gzip,
|
||||
robots: argv.r || argv.robots,
|
||||
ext: argv.e || argv.ext,
|
||||
logFn: logger.request,
|
||||
|
|
|
@ -46,6 +46,7 @@ function HttpServer(options) {
|
|||
this.cache = options.cache === undefined ? 3600 : options.cache; // in seconds.
|
||||
this.showDir = options.showDir !== 'false';
|
||||
this.autoIndex = options.autoIndex !== 'false';
|
||||
this.gzip = options.gzip === true;
|
||||
this.contentType = options.contentType || 'application/octet-stream';
|
||||
|
||||
if (options.ext) {
|
||||
|
@ -97,6 +98,7 @@ function HttpServer(options) {
|
|||
showDir: this.showDir,
|
||||
autoIndex: this.autoIndex,
|
||||
defaultExt: this.ext,
|
||||
gzip: this.gzip,
|
||||
contentType: this.contentType,
|
||||
handleError: typeof options.proxy !== 'string'
|
||||
}));
|
||||
|
|
Загрузка…
Ссылка в новой задаче