Skip to content

Commit e0dec9d

Browse files
committed
Merge branch 'master' into eslint-config
2 parents 46af9d0 + 96aa6e9 commit e0dec9d

26 files changed

+2322
-2278
lines changed

.github/ISSUE_TEMPLATE

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/bug-report.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
---
5+
6+
<!-- Describe the issue briefly here. -->
7+
8+
#### Environment Versions
9+
10+
1. OS Type
11+
1. Node version: `$ node --version`
12+
1. http-server version: `$ http-server --version`
13+
14+
#### Steps to reproduce
15+
16+
<!-- Include the actual command -->
17+
18+
1. ...
19+
2. ...
20+
3. ...
21+
22+
#### Expected result
23+
24+
...
25+
26+
#### Actual result
27+
28+
<!-- Include full output and/or stack trace -->
29+
30+
...
31+
32+
#### Other information
33+
34+
<!-- Include related issues, suggestions for a fix or further debug information, etc. -->
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
---
5+
6+
#### What's the problem this feature will solve?
7+
8+
<!-- What are you trying to do, that you are unable to achieve with http-server as it currently stands? -->
9+
10+
#### Describe the solution you'd like
11+
12+
<!-- A clear and concise description of what you want to happen. -->
13+
14+
<!-- Provide examples of real-world use cases that this would enable and how it solves the problem described above. -->
15+
16+
#### Alternative Solutions
17+
18+
<!-- Have you tried to workaround the problem using http-server or other tools? Or a different approach to solving this issue? Please elaborate here. -->
19+
20+
#### Additional context
21+
22+
<!-- Add any other context, links, etc. about the feature here. -->

.github/PULL_REQUEST_TEMPLATE

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!--- Describe the changes here. --->
2+
3+
##### Relevant issues
4+
5+
<!--
6+
Link to the issue(s) this pull request fixes here, if applicable: "Fixes #xxx" or "Resolves #xxx"
7+
8+
If your PR fixes multiple issues, list them individually like "Fixes #xx1, fixes #xx2, fixes #xx3". This is a quirk of how GitHub links issues.
9+
-->
10+
11+
##### Contributor checklist
12+
13+
- [ ] Provide tests for the changes (unless documentation-only)
14+
- [ ] Documented any new features, CLI switches, etc. (if applicable)
15+
- [ ] Server `--help` output
16+
- [ ] README.md
17+
- [ ] doc/http-server.1 (use the same format as other entries)
18+
- [ ] The pull request is being made against the `master` branch
19+
20+
##### Maintainer checklist
21+
22+
- [ ] Assign a version triage tag
23+
- [ ] Approve tests if applicable

.github/release-drafter.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name-template: 'v$RESOLVED_VERSION'
2+
tag-template: 'v$RESOLVED_VERSION'
3+
4+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
5+
change-title-escapes: '\<*_&'
6+
7+
categories:
8+
- title: 'Breaking changes'
9+
labels:
10+
- 'major version'
11+
- title: 'Features and enhancements'
12+
labels:
13+
- 'feature'
14+
- 'enhancement'
15+
- title: 'Bug Fixes'
16+
labels:
17+
- 'fix'
18+
- 'bug'
19+
- title: 'Other changes'
20+
labels:
21+
- 'dependencies'
22+
- 'documentation'
23+
24+
exclude-labels:
25+
- "skip-changelog"
26+
- "maintenance"
27+
- "trivial"
28+
29+
version-resolver:
30+
major:
31+
labels:
32+
- 'major version'
33+
minor:
34+
labels:
35+
- 'minor version'
36+
patch:
37+
labels:
38+
- 'patch version'
39+
default: patch
40+
41+
template: |
42+
$CHANGES

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
node-version: [10.x, 12.x, 14.x, 16.x]
20+
node-version: [12.x, 14.x, 16.x]
2121
os: [ubuntu-latest, macOS-latest, windows-latest]
2222

2323
steps:

.github/workflows/release-drafter.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: release-drafter
2+
3+
on:
4+
push:
5+
# branches to consider in the event; optional, defaults to all
6+
branches:
7+
- master
8+
9+
jobs:
10+
update_release_draft:
11+
permissions:
12+
contents: write
13+
pull-requests: read
14+
if: github.repository == 'http-party/http-server'
15+
runs-on: ubuntu-latest
16+
steps:
17+
# Drafts your next release notes as pull requests are merged into master
18+
- uses: release-drafter/release-drafter@v5
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ This will install `http-server` globally so that it may be run from the command
5858
|`-U` or `--utc` |Use UTC time format in log messages.| |
5959
|`--log-ip` |Enable logging of the client's IP address |`false` |
6060
|`-P` or `--proxy` |Proxies all requests which can't be resolved locally to the given url. e.g.: -P http://someurl.com | |
61+
|`--proxy-options` |Pass proxy [options](https://github.com/http-party/node-http-proxy#options) using nested dotted objects. e.g.: --proxy-options.secure false |
6162
|`--username` |Username for basic authentication | |
6263
|`--password` |Password for basic authentication | |
63-
|`-S` or `--ssl` |Enable https.| |
64+
|`-S`, `--tls` or `--ssl` |Enable secure request serving with TLS/SSL (HTTPS)|`false`|
6465
|`-C` or `--cert` |Path to ssl cert file |`cert.pem` |
6566
|`-K` or `--key` |Path to ssl key file |`key.pem` |
6667
|`-r` or `--robots` | Automatically provide a /robots.txt (The content of which defaults to `User-agent: *\nDisallow: /`) | `false` |

bin/http-server

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

1420
process.title = 'http-server';
@@ -38,16 +44,17 @@ if (argv.h || argv.help) {
3844
' -U --utc Use UTC time format in log messages.',
3945
' --log-ip Enable logging of the client\'s IP address',
4046
'',
41-
' -P --proxy Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com',
47+
' -P --proxy Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com',
48+
' --proxy-options Pass options to proxy using nested dotted objects. e.g.: --proxy-options.secure false',
4249
'',
4350
' --username Username for basic authentication [none]',
4451
' Can also be specified with the env variable NODE_HTTP_SERVER_USERNAME',
4552
' --password Password for basic authentication [none]',
4653
' Can also be specified with the env variable NODE_HTTP_SERVER_PASSWORD',
4754
'',
48-
' -S --ssl Enable https.',
49-
' -C --cert Path to ssl cert file (default: cert.pem).',
50-
' -K --key Path to ssl key file (default: key.pem).',
55+
' -S --tls --ssl Enable secure request serving with TLS/SSL (HTTPS)',
56+
' -C --cert Path to TLS cert file (default: cert.pem)',
57+
' -K --key Path to TLS key file (default: key.pem)',
5158
'',
5259
' -r --robots Respond to /robots.txt [User-agent: *\\nDisallow: /]',
5360
' --no-dotfiles Do not show dotfiles',
@@ -60,12 +67,26 @@ if (argv.h || argv.help) {
6067

6168
var port = argv.p || argv.port || parseInt(process.env.PORT, 10),
6269
host = argv.a || '0.0.0.0',
63-
ssl = argv.S || argv.ssl,
70+
tls = argv.S || argv.tls,
6471
proxy = argv.P || argv.proxy,
72+
proxyOptions = argv['proxy-options'],
6573
utc = argv.U || argv.utc,
6674
version = argv.v || argv.version,
6775
logger;
6876

77+
var proxyOptionsBooleanProps = [
78+
'ws', 'xfwd', 'secure', 'toProxy', 'prependPath', 'ignorePath', 'changeOrigin',
79+
'preserveHeaderKeyCase', 'followRedirects', 'selfHandleResponse'
80+
];
81+
82+
if (proxyOptions) {
83+
Object.keys(proxyOptions).forEach(function (key) {
84+
if (proxyOptionsBooleanProps.indexOf(key) > -1) {
85+
proxyOptions[key] = proxyOptions[key].toLowerCase() === 'true';
86+
}
87+
});
88+
}
89+
6990
if (!argv.s && !argv.silent) {
7091
logger = {
7192
info: console.log,
@@ -127,6 +148,7 @@ function listen(port) {
127148
ext: argv.e || argv.ext,
128149
logFn: logger.request,
129150
proxy: proxy,
151+
proxyOptions: proxyOptions,
130152
showDotfiles: argv.dotfiles,
131153
mimetypes: argv.mimetypes,
132154
username: argv.username || process.env.NODE_HTTP_SERVER_USERNAME,
@@ -140,7 +162,17 @@ function listen(port) {
140162
}
141163
}
142164

143-
if (ssl) {
165+
if (proxy) {
166+
try {
167+
new url.URL(proxy)
168+
}
169+
catch (err) {
170+
logger.info(colors.red('Error: Invalid proxy url'));
171+
process.exit(1);
172+
}
173+
}
174+
175+
if (tls) {
144176
options.https = {
145177
cert: argv.C || argv.cert || 'cert.pem',
146178
key: argv.K || argv.key || 'key.pem'
@@ -163,16 +195,18 @@ function listen(port) {
163195

164196
var server = httpServer.createServer(options);
165197
server.listen(port, host, function () {
166-
var protocol = ssl ? 'https://' : 'http://';
198+
var protocol = tls ? 'https://' : 'http://';
167199

168-
logger.info([colors.yellow('Starting up http-server, serving '),
200+
logger.info([
201+
colors.yellow('Starting up http-server, serving '),
169202
colors.cyan(server.root),
170-
ssl ? (colors.yellow(' through') + colors.cyan(' https')) : ''
203+
tls ? (colors.yellow(' through') + colors.cyan(' https')) : ''
171204
].join(''));
172205

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

175-
logger.info([colors.yellow('\nhttp-server settings: '),
208+
logger.info([
209+
colors.yellow('\nhttp-server settings: '),
176210
([colors.yellow('CORS: '), argv.cors ? colors.cyan(argv.cors) : colors.red('disabled')].join('')),
177211
([colors.yellow('Cache: '), argv.c ? (argv.c === '-1' ? colors.red('disabled') : colors.cyan(argv.c + ' seconds')) : colors.cyan('3600 seconds')].join('')),
178212
([colors.yellow('Connection Timeout: '), argv.t === '0' ? colors.red('disabled') : (argv.t ? colors.cyan(argv.t + ' seconds') : colors.cyan('120 seconds'))].join('')),
@@ -198,7 +232,12 @@ function listen(port) {
198232
}
199233

200234
if (typeof proxy === 'string') {
201-
logger.info('Unhandled requests will be served from: ' + proxy);
235+
if (proxyOptions) {
236+
logger.info('Unhandled requests will be served from: ' + proxy + '. Options: ' + JSON.stringify(proxyOptions));
237+
}
238+
else {
239+
logger.info('Unhandled requests will be served from: ' + proxy);
240+
}
202241
}
203242

204243
logger.info('Hit CTRL-C to stop the server');

0 commit comments

Comments
 (0)