From 263d8ee7e04cfcc6d272d70c14f8c8777c7d5166 Mon Sep 17 00:00:00 2001 From: Lars Date: Tue, 23 Nov 2021 11:13:32 +0100 Subject: [PATCH 1/3] Added a optional arg for log header of client --- bin/http-server | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/http-server b/bin/http-server index 3b9e59d2..85ae1e7b 100755 --- a/bin/http-server +++ b/bin/http-server @@ -43,6 +43,7 @@ if (argv.h || argv.help) { ' To disable timeout, use -t0', ' -U --utc Use UTC time format in log messages.', ' --log-ip Enable logging of the client\'s IP address', + ' --log-request-headers Enable logging of the client\'s request headers', '', ' -P --proxy Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com', ' --proxy-options Pass options to proxy using nested dotted objects. e.g.: --proxy-options.secure false', @@ -109,6 +110,9 @@ if (!argv.s && !argv.silent) { date, ip, colors.cyan(req.method), colors.cyan(req.url), req.headers['user-agent'] ); + if(argv['log-request-headers']) { + logger.info( '[%s] %s', date, JSON.stringify({headers : req.headers })); + } } } }; From 0d8828a0356a037c9a108b2437ab642c8ce4f49c Mon Sep 17 00:00:00 2001 From: Lars Date: Tue, 23 Nov 2021 11:21:51 +0100 Subject: [PATCH 2/3] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0ffbbc1f..4113a251 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ This will install `http-server` globally so that it may be run from the command |`-c` |Set cache time (in seconds) for cache-control max-age header, e.g. `-c10` for 10 seconds. To disable caching, use `-c-1`.|`3600` | |`-U` or `--utc` |Use UTC time format in log messages.| | |`--log-ip` |Enable logging of the client's IP address |`false` | +|`--log-request-headers` |Enable logging of the client\'s request headers |`false` | |`-P` or `--proxy` |Proxies all requests which can't be resolved locally to the given url. e.g.: -P http://someurl.com | | |`--proxy-options` |Pass proxy [options](https://github.com/http-party/node-http-proxy#options) using nested dotted objects. e.g.: --proxy-options.secure false | |`--username` |Username for basic authentication | | From 90ab228e0d4cb50a6a5da65532f4f6f680afdb46 Mon Sep 17 00:00:00 2001 From: Lars Date: Tue, 23 Nov 2021 11:27:32 +0100 Subject: [PATCH 3/3] Update http-server.1 --- doc/http-server.1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/http-server.1 b/doc/http-server.1 index bbd87e82..6b3e82d6 100644 --- a/doc/http-server.1 +++ b/doc/http-server.1 @@ -81,6 +81,10 @@ Use UTC time format in log messages. .BI \-\-log\-ip Enable logging of the client IP address. +.TP +.BI \-\-log\-request\-headers +Enable logging of the client\'s request headers + .TP .BI \-P ", " \-\-proxy Fallback proxy if the request cannot be resolved.