@e-mc/request 0.10.9 → 0.10.10
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 +4 -4
- package/http/adapter/index.js +7 -2
- package/index.js +9 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.10.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.10.10/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { IModule, ModuleConstructor } from "./index";
|
|
@@ -205,9 +205,9 @@ instance.get("http://hostname/path/config.yml", options).then(data => {
|
|
|
205
205
|
|
|
206
206
|
## References
|
|
207
207
|
|
|
208
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
209
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
210
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
208
|
+
- https://www.unpkg.com/@e-mc/types@0.10.10/lib/http.d.ts
|
|
209
|
+
- https://www.unpkg.com/@e-mc/types@0.10.10/lib/request.d.ts
|
|
210
|
+
- https://www.unpkg.com/@e-mc/types@0.10.10/lib/settings.d.ts
|
|
211
211
|
|
|
212
212
|
* https://www.npmjs.com/package/@types/node
|
|
213
213
|
|
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
|
@@ -676,7 +676,7 @@ class Fetch {
|
|
|
676
676
|
}
|
|
677
677
|
dataLength = Buffer.byteLength(buffer, encoding);
|
|
678
678
|
if (mibsTime) {
|
|
679
|
-
messageUnit =
|
|
679
|
+
messageUnit = this.formatMibs(dataLength, mibsTime);
|
|
680
680
|
}
|
|
681
681
|
if (contentLength > 0) {
|
|
682
682
|
parent.updateProgress("request", progressId, dataLength, dataLength);
|
|
@@ -730,6 +730,9 @@ class Fetch {
|
|
|
730
730
|
this.terminate("No data received");
|
|
731
731
|
return;
|
|
732
732
|
}
|
|
733
|
+
if (mibsTime && (contentLength > 0 || typeof pipeTo === 'string')) {
|
|
734
|
+
messageUnit = this.formatMibs(contentLength || (0, util_1.getSize)(pipeTo), mibsTime);
|
|
735
|
+
}
|
|
733
736
|
result = encoding && !pipeline ? '' : null;
|
|
734
737
|
titleBgColor = 'bgBlue';
|
|
735
738
|
}
|
|
@@ -843,6 +846,11 @@ class Fetch {
|
|
|
843
846
|
formatRetry(message) {
|
|
844
847
|
return message + ` (${this.retries} / ${this.retryLimit})`;
|
|
845
848
|
}
|
|
849
|
+
formatMibs(dataLength, mibsTime) {
|
|
850
|
+
if (dataLength > 0) {
|
|
851
|
+
return (0, util_1.getTransferRate)(dataLength, Math.max(1, (0, types_1.convertTime)(process.hrtime(mibsTime), false) * 1000));
|
|
852
|
+
}
|
|
853
|
+
}
|
|
846
854
|
close() {
|
|
847
855
|
if (this.timeout) {
|
|
848
856
|
clearTimeout(this.timeout);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/request",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.10",
|
|
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": "BSD-3-Clause",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/module": "0.10.
|
|
24
|
-
"@e-mc/types": "0.10.
|
|
23
|
+
"@e-mc/module": "0.10.10",
|
|
24
|
+
"@e-mc/types": "0.10.10",
|
|
25
25
|
"combined-stream": "^1.0.8",
|
|
26
26
|
"js-yaml": "^4.1.0",
|
|
27
27
|
"picomatch": "^4.0.2",
|