Skip to content

Commit

Permalink
Adding contentType cli option to address #276
Browse files Browse the repository at this point in the history
  • Loading branch information
howardroark committed Jun 22, 2016
1 parent 1a8552c commit d127273
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bin/http-server
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if (argv.h || argv.help) {
' -s --silent Suppress log messages from output',
' --cors[=headers] Enable CORS via the "Access-Control-Allow-Origin" header',
' Optionally provide CORS headers list separated by commas',
' --contentType Use a custom Content-Type response header for all requests',
' -o [path] Open browser window after starting the server',
' -c Cache time (max-age) in seconds [3600], e.g. -c10 for 10 seconds.',
' To disable caching, use -c-1.',
Expand Down Expand Up @@ -108,6 +109,10 @@ function listen(port) {
options.corsHeaders = argv.cors;
}
}

if (argv.contentType) {
options.contentType = argv.contentType;
}

if (ssl) {
options.https = {
Expand Down
4 changes: 4 additions & 0 deletions lib/http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ function HttpServer(options) {

res.emit('next');
});

if (options.contentType) {
this.headers['Content-Type'] = options.contentType;
}

if (options.cors) {
this.headers['Access-Control-Allow-Origin'] = '*';
Expand Down

0 comments on commit d127273

Please sign in to comment.