Skip to content

Commit d9bd690

Browse files
committed
Adding contentType cli option to address #276
1 parent 1a8552c commit d9bd690

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

bin/http-server

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ if (argv.h || argv.help) {
2626
' -s --silent Suppress log messages from output',
2727
' --cors[=headers] Enable CORS via the "Access-Control-Allow-Origin" header',
2828
' Optionally provide CORS headers list separated by commas',
29+
' --contentType Use a custom Content-Type response header for all requests',
2930
' -o [path] Open browser window after starting the server',
3031
' -c Cache time (max-age) in seconds [3600], e.g. -c10 for 10 seconds.',
3132
' To disable caching, use -c-1.',
@@ -108,6 +109,10 @@ function listen(port) {
108109
options.corsHeaders = argv.cors;
109110
}
110111
}
112+
113+
if (argv.contentType) {
114+
options.contentType = argv.contentType;
115+
}
111116

112117
if (ssl) {
113118
options.https = {

lib/http-server.js

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ function HttpServer(options) {
6363

6464
res.emit('next');
6565
});
66+
67+
if (options.contentType) {
68+
this.headers['Content-Type'] = options.contentType;
69+
}
6670

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

0 commit comments

Comments
 (0)