http-request-manager 18.15.10 → 18.15.12
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.
|
@@ -973,7 +973,7 @@ class StreamingProcessor {
|
|
|
973
973
|
return null;
|
|
974
974
|
case HttpEventType.DownloadProgress:
|
|
975
975
|
if (event.partialText) {
|
|
976
|
-
this.
|
|
976
|
+
this.buffer = event.partialText;
|
|
977
977
|
const parsedData = this.parseBuffer();
|
|
978
978
|
// Only return NEW items since last parse (progressive updates)
|
|
979
979
|
const newItems = parsedData.slice(this.lastParsedLength);
|
|
@@ -995,7 +995,7 @@ class StreamingProcessor {
|
|
|
995
995
|
return null;
|
|
996
996
|
case HttpEventType.Response:
|
|
997
997
|
if (event.body) {
|
|
998
|
-
this.
|
|
998
|
+
this.buffer = typeof event.body === 'string' ? event.body : this.buffer;
|
|
999
999
|
const parsedData = this.parseBuffer();
|
|
1000
1000
|
// Calculate final progress
|
|
1001
1001
|
const progress = {
|
|
@@ -1065,8 +1065,7 @@ function safeJsonParse(jsonStr, fallback) {
|
|
|
1065
1065
|
try {
|
|
1066
1066
|
return JSON.parse(jsonStr);
|
|
1067
1067
|
}
|
|
1068
|
-
catch
|
|
1069
|
-
console.warn('Failed to parse JSON:', jsonStr.substring(0, 100));
|
|
1068
|
+
catch {
|
|
1070
1069
|
return fallback || null;
|
|
1071
1070
|
}
|
|
1072
1071
|
}
|
|
@@ -1078,8 +1077,7 @@ function safeJsonArrayParse(jsonStr, fallback = []) {
|
|
|
1078
1077
|
const parsed = JSON.parse(jsonStr);
|
|
1079
1078
|
return Array.isArray(parsed) ? parsed : fallback;
|
|
1080
1079
|
}
|
|
1081
|
-
catch
|
|
1082
|
-
console.warn('Failed to parse JSON array:', jsonStr.substring(0, 100));
|
|
1080
|
+
catch {
|
|
1083
1081
|
return fallback;
|
|
1084
1082
|
}
|
|
1085
1083
|
}
|
|
@@ -1179,10 +1177,12 @@ function parseStreamData(buffer, contentType, config) {
|
|
|
1179
1177
|
*/
|
|
1180
1178
|
function parseNdjson(buffer, config) {
|
|
1181
1179
|
const results = [];
|
|
1182
|
-
const lines = buffer.split('\n')
|
|
1183
|
-
|
|
1180
|
+
const lines = buffer.split('\n');
|
|
1181
|
+
// If the buffer doesn't end with \n, the last segment is an incomplete partial line — skip it
|
|
1182
|
+
const completeLines = buffer.endsWith('\n') ? lines : lines.slice(0, -1);
|
|
1183
|
+
completeLines.filter(line => line.trim()).forEach(line => {
|
|
1184
1184
|
const trimmedLine = line.trim();
|
|
1185
|
-
if (trimmedLine && trimmedLine.startsWith('{')
|
|
1185
|
+
if (trimmedLine && trimmedLine.startsWith('{')) {
|
|
1186
1186
|
const parsed = safeJsonParse(trimmedLine);
|
|
1187
1187
|
if (parsed)
|
|
1188
1188
|
results.push(parsed);
|
|
@@ -2954,7 +2954,9 @@ class RequestService extends WebsocketService {
|
|
|
2954
2954
|
observe: 'events',
|
|
2955
2955
|
responseType: 'text',
|
|
2956
2956
|
reportProgress: true
|
|
2957
|
-
}).pipe(
|
|
2957
|
+
}).pipe(
|
|
2958
|
+
// tap(data => console.log('STREAM DATA', data)),
|
|
2959
|
+
requestStreaming({ streamType: options.streamType || StreamType.NDJSON }), this.requestStreaming(options), this.handleFinalize())
|
|
2958
2960
|
: this.http.get(urlPath, headers).pipe(this.request(options));
|
|
2959
2961
|
}
|
|
2960
2962
|
createRecordRequest(options, data) {
|