Skip to content

Commit bdf879a

Browse files
committed
make ssl an alias of tls
1 parent 35ff346 commit bdf879a

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ This will install `http-server` globally so that it may be run from the command
6262

6363
|`--username` |Username for basic authentication | |
6464
|`--password` |Password for basic authentication | |
65-
|`-S` or `--ssl` |Enable https.| |
65+
|`-S`, `--tls` or `--ssl` |Enable secure request serving with TLS/SSL (HTTPS)|`false`|
6666
|`-C` or `--cert` |Path to ssl cert file |`cert.pem` |
6767
|`-K` or `--key` |Path to ssl key file |`key.pem` |
6868
|`-r` or `--robots` | Automatically provide a /robots.txt (The content of which defaults to `User-agent: *\nDisallow: /`) | `false` |

bin/http-server

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ var colors = require('colors/safe'),
77
httpServer = require('../lib/http-server'),
88
portfinder = require('portfinder'),
99
opener = require('opener'),
10-
fs = require('fs'),
11-
argv = require('minimist')(process.argv.slice(2));
10+
fs = require('fs');
11+
var argv = require('minimist')(process.argv.slice(2), {
12+
alias: {
13+
tls: 'ssl'
14+
}
15+
});
1216
var ifaces = os.networkInterfaces();
1317

1418
process.title = 'http-server';
@@ -38,17 +42,17 @@ if (argv.h || argv.help) {
3842
' -U --utc Use UTC time format in log messages.',
3943
' --log-ip Enable logging of the client\'s IP address',
4044
'',
41-
' -P --proxy Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com',
45+
' -P --proxy Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com',
4246
' --proxy-options Pass options to proxy using nested dotted objects. e.g.: --proxy-options.secure false',
4347
'',
4448
' --username Username for basic authentication [none]',
4549
' Can also be specified with the env variable NODE_HTTP_SERVER_USERNAME',
4650
' --password Password for basic authentication [none]',
4751
' Can also be specified with the env variable NODE_HTTP_SERVER_PASSWORD',
4852
'',
49-
' -S --ssl Enable https.',
50-
' -C --cert Path to ssl cert file (default: cert.pem).',
51-
' -K --key Path to ssl key file (default: key.pem).',
53+
' -S --tls --ssl Enable secure request serving with TLS/SSL (HTTPS)',
54+
' -C --cert Path to TLS cert file (default: cert.pem)',
55+
' -K --key Path to TLS key file (default: key.pem)',
5256
'',
5357
' -r --robots Respond to /robots.txt [User-agent: *\\nDisallow: /]',
5458
' --no-dotfiles Do not show dotfiles',
@@ -61,7 +65,7 @@ if (argv.h || argv.help) {
6165

6266
var port = argv.p || argv.port || parseInt(process.env.PORT, 10),
6367
host = argv.a || '0.0.0.0',
64-
ssl = argv.S || argv.ssl,
68+
tls = argv.S || argv.tls,
6569
proxy = argv.P || argv.proxy,
6670
proxyOptions = argv['proxy-options'],
6771
utc = argv.U || argv.utc,
@@ -156,7 +160,7 @@ function listen(port) {
156160
}
157161
}
158162

159-
if (ssl) {
163+
if (tls) {
160164
options.https = {
161165
cert: argv.C || argv.cert || 'cert.pem',
162166
key: argv.K || argv.key || 'key.pem'
@@ -179,16 +183,18 @@ function listen(port) {
179183

180184
var server = httpServer.createServer(options);
181185
server.listen(port, host, function () {
182-
var protocol = ssl ? 'https://' : 'http://';
186+
var protocol = tls ? 'https://' : 'http://';
183187

184-
logger.info([colors.yellow('Starting up http-server, serving '),
188+
logger.info([
189+
colors.yellow('Starting up http-server, serving '),
185190
colors.cyan(server.root),
186-
ssl ? (colors.yellow(' through') + colors.cyan(' https')) : ''
191+
tls ? (colors.yellow(' through') + colors.cyan(' https')) : ''
187192
].join(''));
188193

189194
logger.info([colors.yellow('\nhttp-server version: '), colors.cyan(require('../package.json').version)].join(''));
190195

191-
logger.info([colors.yellow('\nhttp-server settings: '),
196+
logger.info([
197+
colors.yellow('\nhttp-server settings: '),
192198
([colors.yellow('CORS: '), argv.cors ? colors.cyan(argv.cors) : colors.red('disabled')].join('')),
193199
([colors.yellow('Cache: '), argv.c ? (argv.c === '-1' ? colors.red('disabled') : colors.cyan(argv.c + ' seconds')) : colors.cyan('3600 seconds')].join('')),
194200
([colors.yellow('Connection Timeout: '), argv.t === '0' ? colors.red('disabled') : (argv.t ? colors.cyan(argv.t + ' seconds') : colors.cyan('120 seconds'))].join('')),

doc/http-server.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Can also be specified with the environment variable NODE_HTTP_SERVER_PASSWORD.
102102
Defaults to none.
103103

104104
.TP
105-
.BI \-S ", " \-\-ssl
105+
.BI \-S ", " \-\-tls ", " \-\-ssl
106106
Enable https.
107107

108108
.TP

lib/http-server.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ function HttpServer(options) {
3333

3434
if (options.root) {
3535
this.root = options.root;
36-
}
37-
else {
36+
} else {
3837
try {
3938
fs.lstatSync('./public');
4039
this.root = './public';

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/proxy-options.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ test('proxy options', (t) => {
3535
brotli: true,
3636
gzip: true
3737
})
38+
// TODO #723 we should use portfinder
3839
server.listen(8080, async () => {
3940
try {
4041

4142
// Another server proxies 8081 to 8080
4243
const proxyServer = httpServer.createServer({
4344
proxy: 'http://localhost:8080',
4445
root: path.join(__dirname, 'fixtures'),
45-
ssl: true,
46+
tls: true,
4647
https: httpsOpts,
4748
proxyOptions: {
4849
secure: false

0 commit comments

Comments
 (0)