Skip to content

Commit a2e7721

Browse files
committedNov 9, 2019
Merge branch 'master' into hacky-fix
2 parents c4956ec + 6260536 commit a2e7721

File tree

7 files changed

+69
-13
lines changed

7 files changed

+69
-13
lines changed
 

‎.travis.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- "4"
5-
- "5"
64
- "6"
7-
- "7"
5+
- "8"
6+
- "10"
7+
- "12"
8+
- "13"
89

910
before_install:
1011
- travis_retry npm install

‎README.md

+10
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ Using `npx` you can run the script without installing it first:
7575

7676
`-r` or `--robots` Provide a /robots.txt (whose content defaults to `User-agent: *\nDisallow: /`)
7777

78+
`--no-dotfiles` Do not show dotfiles
79+
7880
`-h` or `--help` Print this list and exit.
7981

8082
## Magic Files
@@ -92,6 +94,14 @@ http-server --proxy http://localhost:8080?
9294

9395
Note the `?` at the end of the proxy URL. Thanks to [@houston3](https://github.com/houston3) for this clever hack!
9496

97+
## Need a self signed SSL Certificate?
98+
99+
Create the `cert.pem` and `key.pem` via the command:
100+
101+
```
102+
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
103+
```
104+
95105
# Development
96106

97107
Checkout this repository locally, then:

‎bin/http-server

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ var colors = require('colors/safe'),
1414

1515
var ifaces = os.networkInterfaces();
1616

17+
process.title = 'http-server';
18+
1719
if (argv.h || argv.help) {
1820
console.log([
1921
'usage: http-server [path] [options]',
@@ -34,6 +36,8 @@ if (argv.h || argv.help) {
3436
' Optionally provide a URL path to open the browser window to.',
3537
' -c Cache time (max-age) in seconds [3600], e.g. -c10 for 10 seconds.',
3638
' To disable caching, use -c-1.',
39+
' -t Connections timeout in seconds [120], e.g. -t60 for 1 minute.',
40+
' To disable timeout, use -t0',
3741
' -U --utc Use UTC time format in log messages.',
3842
' --log-ip Enable logging of the client\'s IP address',
3943
'',
@@ -109,6 +113,7 @@ function listen(port) {
109113
var options = {
110114
root: argv._[0],
111115
cache: argv.c,
116+
timeout: argv.t,
112117
showDir: argv.d,
113118
autoIndex: argv.i,
114119
gzip: argv.g || argv.gzip,

‎lib/http-server.js

+3
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ function HttpServer(options) {
195195
}
196196

197197
this.server = union.createServer(serverOptions);
198+
if (options.timeout !== undefined) {
199+
this.server.setTimeout(options.timeout);
200+
}
198201
}
199202

200203
HttpServer.prototype.listen = function () {

‎package-lock.json

+25-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
},
1010
"keywords": [
1111
"cli",
12-
"command"
12+
"command",
13+
"http",
14+
"server"
1315
],
1416
"scripts": {
1517
"start": "node ./bin/http-server",
@@ -20,6 +22,9 @@
2022
"lib",
2123
"bin"
2224
],
25+
"engines": {
26+
"node": ">=6"
27+
},
2328
"contributors": [
2429
{
2530
"name": "Charlie Robbins",
@@ -84,7 +89,7 @@
8489
"devDependencies": {
8590
"common-style": "^3.0.0",
8691
"request": "^2.88.0",
87-
"vows": "~0.7.0"
92+
"vows": "~0.8.3"
8893
},
8994
"bugs": {
9095
"url": "https://github.com/nodeapps/http-server/issues"

‎test/http-server-test.js

+15
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,13 @@ vows.describe('http-server').addBatch({
125125
assert.equal(body.trim(), file.trim());
126126
}
127127
}
128+
},
129+
teardown: function (proxyServer) {
130+
proxyServer.close();
128131
}
132+
},
133+
teardown: function (server) {
134+
server.close();
129135
}
130136
},
131137
'When cors is enabled': {
@@ -156,6 +162,9 @@ vows.describe('http-server').addBatch({
156162
'response Access-Control-Allow-Headers should contain X-Test': function (err, res) {
157163
assert.ok(res.headers['access-control-allow-headers'].split(/\s*,\s*/g).indexOf('X-Test') >= 0, 204);
158164
}
165+
},
166+
teardown: function (server) {
167+
server.close();
159168
}
160169
},
161170
'When gzip and brotli compression is enabled and a compressed file is available': {
@@ -209,6 +218,9 @@ vows.describe('http-server').addBatch({
209218
assert.equal(res.statusCode, 200);
210219
assert.equal(res.headers['content-encoding'], 'br');
211220
}
221+
},
222+
teardown: function (server) {
223+
server.close();
212224
}
213225
},
214226
'When http-server is listening on 8083 with username "good_username" and password "good_password"': {
@@ -341,6 +353,9 @@ vows.describe('http-server').addBatch({
341353
assert.equal(body.trim(), file.trim());
342354
}
343355
}
356+
},
357+
teardown: function (server) {
358+
server.close();
344359
}
345360
}
346361
}).export(module);

0 commit comments

Comments
 (0)
Please sign in to comment.