Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ with the provided Dockerfile.
|`-o [path]` |Open browser window after starting the server. Optionally provide a URL path to open. e.g.: -o /other/dir/ | |
|`-c` |Set cache time (in seconds) for cache-control max-age header, e.g. `-c10` for 10 seconds. To disable caching, use `-c-1`.|`3600` |
|`-t` |Connection timeout in seconds, e.g. `-t60` for 1 minute. To disable timeout, use `-t0`.|`120` |
|`-T` or `--title` |Custom title suffix for the terminal window. The title will be "http-server PORT [TITLE]".| |
|`-U` or `--utc` |Use UTC time format in log messages.| |
|`--log-ip` |Enable logging of the client's IP address |`false` |
|`-P` or `--proxy` |Proxies all requests which can't be resolved locally to the given url. e.g.: -P http://someurl.com | |
Expand Down
8 changes: 6 additions & 2 deletions bin/http-server
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ var argv = require('minimist')(process.argv.slice(2), {

var ifaces = os.networkInterfaces();

process.title = 'http-server';

if (argv.h || argv.help) {
console.log([
'usage: http-server [path] [options]',
Expand Down Expand Up @@ -64,6 +62,8 @@ if (argv.h || argv.help) {
' To disable caching, use -c-1.',
' -t Connection timeout in seconds [120], e.g. -t60 for 1 minute.',
' To disable timeout, use -t0.',
' -T --title Custom title suffix for the terminal window [none]',
' The terminal title will be "http-server PORT [TITLE]"',
' -U --utc Use UTC time format in log messages.',
' --log-ip Enable logging of the client\'s IP address',
'',
Expand Down Expand Up @@ -94,6 +94,7 @@ if (argv.h || argv.help) {
var port = argv.p || argv.port || parseInt(process.env.PORT, 10),
host = argv.a || '::',
tls = argv.S || argv.tls,
title = argv.T || argv.title,
sslPassphrase = process.env.NODE_HTTP_SERVER_SSL_PASSPHRASE,
proxy = argv.P || argv.proxy,
proxyOptions = argv['proxy-options'],
Expand Down Expand Up @@ -311,6 +312,9 @@ function listen(port) {

var server = httpServer.createServer(options);
server.listen(port, host, function () {
// Set process title with port and optional custom suffix
process.title = 'http-server ' + port + (title ? ' ' + title : '');

var protocol = tls ? 'https://' : 'http://',
path = baseDir ? '/' + baseDir.replace(/^\//, '') : '';

Expand Down
5 changes: 5 additions & 0 deletions doc/http-server.1
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ Connection timeout in seconds, e.g. -t60 for 1 minute.
To disable timeout, use \-t0.
Default is 120.

.TP
.BI \-T ", " \-\-title " " \fITITLE\fR
Custom title suffix for the terminal window.
The terminal title will be "http-server PORT [TITLE]".

.TP
.BI \-U ", " \-\-utc
Use UTC time format in log messages.
Expand Down
Loading