http-request-manager 18.15.22 → 18.15.23
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.
|
@@ -978,14 +978,19 @@ class StreamingProcessor {
|
|
|
978
978
|
// Only return NEW items since last parse (progressive updates)
|
|
979
979
|
const newItems = parsedData.slice(this.lastParsedLength);
|
|
980
980
|
this.lastParsedLength = parsedData.length;
|
|
981
|
-
// Calculate progress
|
|
981
|
+
// Calculate progress — prefer record count from header, fall back to byte-level
|
|
982
|
+
const total = this.totalFromHeader ?? event.total;
|
|
983
|
+
const received = this.totalFromHeader ? this.lastParsedLength : event.loaded;
|
|
984
|
+
const percent = total
|
|
985
|
+
? Math.round((received / total) * 100)
|
|
986
|
+
: 0;
|
|
982
987
|
const progress = {
|
|
983
|
-
received
|
|
984
|
-
total
|
|
985
|
-
percent
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
988
|
+
received,
|
|
989
|
+
total,
|
|
990
|
+
percent,
|
|
991
|
+
stage: 'streaming',
|
|
992
|
+
bytesLoaded: event.loaded,
|
|
993
|
+
bytesTotal: event.total
|
|
989
994
|
};
|
|
990
995
|
return {
|
|
991
996
|
data: newItems.length > 0 ? newItems : [],
|
|
@@ -997,14 +1002,16 @@ class StreamingProcessor {
|
|
|
997
1002
|
if (event.body) {
|
|
998
1003
|
this.buffer = typeof event.body === 'string' ? event.body : this.buffer;
|
|
999
1004
|
const parsedData = this.parseBuffer();
|
|
1000
|
-
// Calculate final progress
|
|
1005
|
+
// Calculate final progress — prefer record count from header, fall back to byte-level
|
|
1006
|
+
const total = this.totalFromHeader ?? event.total;
|
|
1007
|
+
const received = this.totalFromHeader ? parsedData.length : event.loaded;
|
|
1001
1008
|
const progress = {
|
|
1002
|
-
received
|
|
1003
|
-
total
|
|
1004
|
-
percent:
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1009
|
+
received,
|
|
1010
|
+
total,
|
|
1011
|
+
percent: 100,
|
|
1012
|
+
stage: 'complete',
|
|
1013
|
+
bytesLoaded: event.loaded,
|
|
1014
|
+
bytesTotal: event.total
|
|
1008
1015
|
};
|
|
1009
1016
|
return {
|
|
1010
1017
|
data: parsedData.length > 0 ? parsedData : [],
|