Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bin/http-server
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var colors = require('colors'),
httpServer = require('../lib/http-server'),
portfinder = require('portfinder'),
opener = require('opener'),
columnify = require('columnify'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer that we either don't add a new dependency, or use it for all logging (and the help output).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a big fan of adding this dependency. It does make the headers look better, but I'm not sure we need the extra baggage to do that. I think util.format should do just fine without any extra libraries

argv = require('optimist')
.boolean('cors')
.argv;
Expand Down Expand Up @@ -38,6 +39,7 @@ if (argv.h || argv.help) {
' -K --key Path to ssl key file (default: key.pem).',
'',
' -r --robots Respond to /robots.txt [User-agent: *\\nDisallow: /]',
' -v --verbose Log out the full headers of each request along with the typical content',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now have -v implemented as the short option for --version, which I think is fine. This option could be just --verbose with no short version.

On the other hand, since http-server is pretty verbose by default, I wonder if this might be better called --very-verbose?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also move this up next to --silent to keep it all together?

Copy link
Member

@thornjad thornjad Dec 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also should to be added to the README and doc/http-server.1

' -h --help Print this list and exit.'
].join('\n'));
process.exit();
Expand Down Expand Up @@ -68,6 +70,14 @@ if (!argv.s && !argv.silent) {
date, req.method.cyan, req.url.cyan,
req.headers['user-agent']
);
if (argv.v || argv.verbose) {
var headerString = columnify(req.headers,
{ columns: ['Header', 'Value'] });
logger.info(
'%s',
headerString
);
}
}
}
};
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
],
"dependencies": {
"colors": "1.0.3",
"columnify": "^1.5.4",
"corser": "~2.0.0",
"ecstatic": "^1.4.0",
"http-proxy": "^1.8.1",
Expand Down