pixl-server-web 1.3.26 → 1.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/lib/response.js +9 -4
- package/package.json +1 -1
- package/web_server.js +2 -0
package/README.md
CHANGED
|
@@ -35,6 +35,8 @@ This module is a component for use in [pixl-server](https://www.github.com/jhuck
|
|
|
35
35
|
* [http_brotli_opts](#http_brotli_opts)
|
|
36
36
|
* [http_default_acl](#http_default_acl)
|
|
37
37
|
* [http_log_requests](#http_log_requests)
|
|
38
|
+
* [http_log_request_details](#http_log_request_details)
|
|
39
|
+
* [http_log_body_max](#http_log_body_max)
|
|
38
40
|
* [http_regex_log](#http_regex_log)
|
|
39
41
|
* [http_log_perf](#http_log_perf)
|
|
40
42
|
* [http_perf_threshold_ms](#http_perf_threshold_ms)
|
|
@@ -88,6 +90,7 @@ This module is a component for use in [pixl-server](https://www.github.com/jhuck
|
|
|
88
90
|
+ [args.id](#argsid)
|
|
89
91
|
* [Request Filters](#request-filters)
|
|
90
92
|
- [Transaction Logging](#transaction-logging)
|
|
93
|
+
* [Request Detail Logging](#request-detail-logging)
|
|
91
94
|
* [Performance Threshold Logging](#performance-threshold-logging)
|
|
92
95
|
+ [Including Diagnostic Reports](#including-diagnostic-reports)
|
|
93
96
|
* [Including Custom Metrics](#including-custom-metrics)
|
|
@@ -426,6 +429,14 @@ This boolean allows you to enable transaction logging in the web server. It def
|
|
|
426
429
|
|
|
427
430
|
This boolean adds verbose detail in the transaction log. It defaults to `false` (disabled). See [Transaction Logging](#transaction-logging) below for details.
|
|
428
431
|
|
|
432
|
+
**Note:** This property only has effect if [http_log_requests](#http_log_requests) is enabled.
|
|
433
|
+
|
|
434
|
+
## http_log_body_max
|
|
435
|
+
|
|
436
|
+
This property sets the maximum allowed request and response body length that can be logged, when [http_log_request_details](#http_log_request_details) is enabled. If the request or response body length exceeds this amount, they will not be included in the transaction log.
|
|
437
|
+
|
|
438
|
+
**Note:** This property only has effect if [http_log_request_details](#http_log_request_details) is enabled.
|
|
439
|
+
|
|
429
440
|
## http_regex_log
|
|
430
441
|
|
|
431
442
|
If [http_log_requests](#http_log_requests) is enabled, this allows you to specify a regular expression to match against incoming request URIs. Only requests that match will be logged. It defaults to match all URIs (`.+`). See [Transaction Logging](#transaction-logging) below for details.
|
|
@@ -1172,7 +1183,6 @@ If you set both the [http_log_requests](#http_log_requests) and [http_log_reques
|
|
|
1172
1183
|
"content-type": "application/json",
|
|
1173
1184
|
"x-joetest": "9876",
|
|
1174
1185
|
"server": "Test Server 1.0",
|
|
1175
|
-
"x-200": "YUP BRO",
|
|
1176
1186
|
"content-length": "261",
|
|
1177
1187
|
"content-encoding": "gzip"
|
|
1178
1188
|
},
|
package/lib/response.js
CHANGED
|
@@ -346,35 +346,40 @@ module.exports = class Response {
|
|
|
346
346
|
data.query = args.query || {};
|
|
347
347
|
data.params = Object.assign( {}, args.params || {} );
|
|
348
348
|
|
|
349
|
+
// special handling for raw request body
|
|
349
350
|
if (data.params.raw && data.params.raw.buffer && data.params.raw.toString) {
|
|
350
|
-
if (args.request.headers['content-type'] && args.request.headers['content-type'].match(/(text|javascript|json|xml)/)) {
|
|
351
|
+
if (args.request.headers['content-type'] && args.request.headers['content-type'].match(/(text|javascript|json|xml)/) && (data.params.raw.length <= this.logRequestBodyMax)) {
|
|
351
352
|
data.params.raw = data.params.raw.toString('utf8');
|
|
352
353
|
}
|
|
353
|
-
else data.params.raw = '(
|
|
354
|
+
else data.params.raw = '(Buffer)';
|
|
354
355
|
}
|
|
355
356
|
|
|
357
|
+
// include details on response as well
|
|
356
358
|
data.response = {
|
|
357
359
|
code: args.http_code,
|
|
358
360
|
status: args.http_status,
|
|
359
361
|
headers: {}
|
|
360
362
|
};
|
|
361
363
|
|
|
364
|
+
// convert header keys to lower-case
|
|
362
365
|
if (args.resp_headers) {
|
|
363
366
|
for (var key in args.resp_headers) {
|
|
364
367
|
data.response.headers[ key.toLowerCase() ] = args.resp_headers[key];
|
|
365
368
|
}
|
|
366
369
|
}
|
|
367
370
|
|
|
371
|
+
// special handling for stream and buffer responses
|
|
368
372
|
if (args.resp_body && args.resp_body.pipe) {
|
|
369
373
|
data.response.raw = '(Stream)';
|
|
370
374
|
}
|
|
371
375
|
else if (args.resp_body && args.resp_body.buffer && args.resp_body.toString) {
|
|
372
|
-
if (data.response.headers && data.response.headers['content-type'] && data.response.headers['content-type'].match(/(text|javascript|json|xml)/)) {
|
|
376
|
+
if (data.response.headers && data.response.headers['content-type'] && data.response.headers['content-type'].match(/(text|javascript|json|xml)/) && (args.resp_body.length <= this.logRequestBodyMax)) {
|
|
373
377
|
data.response.raw = args.resp_body.toString('utf8');
|
|
374
378
|
}
|
|
375
|
-
else data.response.raw = '(
|
|
379
|
+
else data.response.raw = '(Buffer)';
|
|
376
380
|
}
|
|
377
381
|
|
|
382
|
+
// cleanup
|
|
378
383
|
delete args.resp_body;
|
|
379
384
|
delete args.resp_headers;
|
|
380
385
|
}
|
package/package.json
CHANGED
package/web_server.js
CHANGED
|
@@ -48,6 +48,7 @@ module.exports = Class({
|
|
|
48
48
|
"http_default_acl": ['127.0.0.1', '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '::1/128', 'fd00::/8', '169.254.0.0/16', 'fe80::/10'],
|
|
49
49
|
"http_log_requests": false,
|
|
50
50
|
"http_log_request_details": false,
|
|
51
|
+
"http_log_body_max": 32768,
|
|
51
52
|
"http_log_perf": false,
|
|
52
53
|
"http_perf_threshold_ms": 100,
|
|
53
54
|
"http_perf_report": false,
|
|
@@ -104,6 +105,7 @@ class WebServer extends Component {
|
|
|
104
105
|
this.regexJSONContent = new RegExp( this.config.get('http_regex_json'), "i" );
|
|
105
106
|
this.logRequests = this.config.get('http_log_requests');
|
|
106
107
|
this.logRequestDetails = this.config.get('http_log_request_details');
|
|
108
|
+
this.logRequestBodyMax = this.config.get('http_log_body_max');
|
|
107
109
|
this.regexLogRequests = this.logRequests ? (new RegExp( this.config.get('http_regex_log') || '.+' )) : null;
|
|
108
110
|
this.logPerfEnabled = this.config.get('http_log_perf');
|
|
109
111
|
this.logPerfThreshold = this.config.get('http_perf_threshold_ms');
|