@@ -12,7 +12,7 @@ const version_id = '7.7.x',
1212
1313/** @summary version date
1414 * @desc Release date in format day/month/year like '14/04/2022' */
15- version_date = '28 /10/2024',
15+ version_date = '30 /10/2024',
1616
1717/** @summary version id and date
1818 * @desc Produced by concatenation of {@link version_id} and {@link version_date}
@@ -99272,7 +99272,7 @@ class TFile {
9927299272 // multipart messages requires special handling
9927399273
9927499274 const indx = hdr.indexOf('boundary=');
99275- let boundary = '', n = first, o = 0;
99275+ let boundary = '', n = first, o = 0, normal_order = true ;
9927699276 if (indx > 0) {
9927799277 boundary = hdr.slice(indx + 9);
9927899278 if ((boundary[0] === '"') && (boundary[boundary.length - 1] === '"'))
@@ -99326,12 +99326,34 @@ class TFile {
9932699326 blobs.push(new DataView(res, o, place[n + 1]));
9932799327 o += place[n + 1];
9932899328 n += 2;
99329- } else {
99329+ } else if (normal_order) {
99330+ const n0 = n;
9933099331 while ((n < last) && (place[n] >= segm_start) && (place[n] + place[n + 1] - 1 <= segm_last)) {
9933199332 blobs.push(new DataView(res, o + place[n] - segm_start, place[n + 1]));
9933299333 n += 2;
9933399334 }
9933499335
99336+ if (n > n0)
99337+ o += (segm_last - segm_start + 1);
99338+ else
99339+ normal_order = false;
99340+ }
99341+
99342+ if (!normal_order) {
99343+ // special situation when server reorder segments in the reply
99344+ let isany = false;
99345+ for (let n1 = n; n1 < last; n1 += 2) {
99346+ if ((place[n1] >= segm_start) && (place[n1] + place[n1 + 1] - 1 <= segm_last)) {
99347+ blobs[n1/2] = new DataView(res, o + place[n1] - segm_start, place[n1 + 1]);
99348+ isany = true;
99349+ }
99350+ }
99351+ if (!isany)
99352+ return rejectFunc(Error(`Provided fragment ${segm_start} - ${segm_last} out of requested multi-range request`));
99353+
99354+ while (blobs[n/2])
99355+ n += 2;
99356+
9933599357 o += (segm_last - segm_start + 1);
9933699358 }
9933799359 }
0 commit comments