http-request-manager 18.15.22 → 18.15.24

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,13 +978,16 @@ 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: this.lastParsedLength,
984
- total: this.totalFromHeader,
985
- percent: this.totalFromHeader
986
- ? Math.round((this.lastParsedLength / this.totalFromHeader) * 100)
987
- : 0,
988
+ received,
989
+ total,
990
+ percent,
988
991
  stage: 'streaming'
989
992
  };
990
993
  return {
@@ -997,13 +1000,13 @@ class StreamingProcessor {
997
1000
  if (event.body) {
998
1001
  this.buffer = typeof event.body === 'string' ? event.body : this.buffer;
999
1002
  const parsedData = this.parseBuffer();
1000
- // Calculate final progress
1003
+ // Calculate final progress — prefer record count from header, fall back to byte-level
1004
+ const total = this.totalFromHeader ?? event.total;
1005
+ const received = this.totalFromHeader ? parsedData.length : event.loaded;
1001
1006
  const progress = {
1002
- received: parsedData.length,
1003
- total: this.totalFromHeader,
1004
- percent: this.totalFromHeader
1005
- ? Math.round((parsedData.length / this.totalFromHeader) * 100)
1006
- : 100,
1007
+ received,
1008
+ total,
1009
+ percent: 100,
1007
1010
  stage: 'complete'
1008
1011
  };
1009
1012
  return {