@e-mc/request 0.5.18 → 0.5.20
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/http/adapter/index.js +7 -2
- package/index.js +1 -1
- package/package.json +3 -3
package/http/adapter/index.js
CHANGED
|
@@ -365,6 +365,7 @@ class HttpAdapter {
|
|
|
365
365
|
this.terminate("No data received");
|
|
366
366
|
return;
|
|
367
367
|
}
|
|
368
|
+
dataLength = this.contentLength || (typeof this.pipeTo === 'string' ? (0, util_1.getSize)(this.pipeTo) : 0);
|
|
368
369
|
result = encoding && !pipeline ? '' : null;
|
|
369
370
|
}
|
|
370
371
|
this.endResponse(result, dataLength, log);
|
|
@@ -377,12 +378,11 @@ class HttpAdapter {
|
|
|
377
378
|
}
|
|
378
379
|
endResponse(result, dataLength = 0, logging = this.state.log) {
|
|
379
380
|
if (logging) {
|
|
380
|
-
const messageUnit = this.dataTime && dataLength > 0 ? (0, util_1.getTransferRate)(dataLength, (0, types_1.convertTime)(process.hrtime.bigint() - this.dataTime, false) * 1000) : undefined;
|
|
381
381
|
this.instance.writeTimeProcess('HTTP' + this.httpVersion, this.opts.statusMessage || this.uri.toString(), this.startTime, {
|
|
382
382
|
type: 1024,
|
|
383
383
|
queue: !!this.instance.host,
|
|
384
384
|
titleBgColor: !result ? 'bgBlue' : undefined,
|
|
385
|
-
messageUnit,
|
|
385
|
+
messageUnit: this.formatMibs(dataLength),
|
|
386
386
|
messageUnitMinWidth: 9,
|
|
387
387
|
delayTime: this.delayTime,
|
|
388
388
|
bypassLog: module_1.hasLogType(32768)
|
|
@@ -494,6 +494,11 @@ class HttpAdapter {
|
|
|
494
494
|
formatStatus(value, hint) {
|
|
495
495
|
return value + ': ' + (hint || (0, util_1.fromStatusCode)(value)) + ` (${this.uri.toString()})`;
|
|
496
496
|
}
|
|
497
|
+
formatMibs(dataLength) {
|
|
498
|
+
if (dataLength > 0 && this.dataTime) {
|
|
499
|
+
return (0, util_1.getTransferRate)(dataLength, Math.max(1, (0, types_1.convertTime)(process.hrtime.bigint() - this.dataTime, false) * 1000));
|
|
500
|
+
}
|
|
501
|
+
}
|
|
497
502
|
close() {
|
|
498
503
|
this.closed = true;
|
|
499
504
|
this.instance.reset(this);
|
package/index.js
CHANGED
|
@@ -1918,7 +1918,7 @@ class Request extends module_1.default {
|
|
|
1918
1918
|
}
|
|
1919
1919
|
}
|
|
1920
1920
|
if (mibsTime) {
|
|
1921
|
-
const unit = (Buffer.byteLength(buffer, encoding) * 8) / ((0, types_1.convertTime)(process.hrtime(mibsTime)) * 1000);
|
|
1921
|
+
const unit = (Buffer.byteLength(buffer, encoding) * 8) / Math.max(1, (0, types_1.convertTime)(process.hrtime(mibsTime)) * 1000);
|
|
1922
1922
|
if (unit < 1) {
|
|
1923
1923
|
messageUnit = Math.ceil(unit * 1000) + 'KiB/s';
|
|
1924
1924
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/request",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.20",
|
|
4
4
|
"description": "Request constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/module": "0.5.
|
|
24
|
-
"@e-mc/types": "0.5.
|
|
23
|
+
"@e-mc/module": "0.5.20",
|
|
24
|
+
"@e-mc/types": "0.5.20",
|
|
25
25
|
"combined-stream": "^1.0.8",
|
|
26
26
|
"js-yaml": "^4.1.0",
|
|
27
27
|
"which": "^2.0.2"
|