diff --git a/build/jsroot.js b/build/jsroot.js index 9dfba3da9..cbff307da 100644 --- a/build/jsroot.js +++ b/build/jsroot.js @@ -12,7 +12,7 @@ const version_id = '7.7.x', /** @summary version date * @desc Release date in format day/month/year like '14/04/2022' */ -version_date = '28/10/2024', +version_date = '30/10/2024', /** @summary version id and date * @desc Produced by concatenation of {@link version_id} and {@link version_date} @@ -99272,7 +99272,7 @@ class TFile { // multipart messages requires special handling const indx = hdr.indexOf('boundary='); - let boundary = '', n = first, o = 0; + let boundary = '', n = first, o = 0, normal_order = true; if (indx > 0) { boundary = hdr.slice(indx + 9); if ((boundary[0] === '"') && (boundary[boundary.length - 1] === '"')) @@ -99326,12 +99326,34 @@ class TFile { blobs.push(new DataView(res, o, place[n + 1])); o += place[n + 1]; n += 2; - } else { + } else if (normal_order) { + const n0 = n; while ((n < last) && (place[n] >= segm_start) && (place[n] + place[n + 1] - 1 <= segm_last)) { blobs.push(new DataView(res, o + place[n] - segm_start, place[n + 1])); n += 2; } + if (n > n0) + o += (segm_last - segm_start + 1); + else + normal_order = false; + } + + if (!normal_order) { + // special situation when server reorder segments in the reply + let isany = false; + for (let n1 = n; n1 < last; n1 += 2) { + if ((place[n1] >= segm_start) && (place[n1] + place[n1 + 1] - 1 <= segm_last)) { + blobs[n1/2] = new DataView(res, o + place[n1] - segm_start, place[n1 + 1]); + isany = true; + } + } + if (!isany) + return rejectFunc(Error(`Provided fragment ${segm_start} - ${segm_last} out of requested multi-range request`)); + + while (blobs[n/2]) + n += 2; + o += (segm_last - segm_start + 1); } } diff --git a/changes.md b/changes.md index 14e855c3e..d4fc12967 100644 --- a/changes.md +++ b/changes.md @@ -6,6 +6,7 @@ 3. Fix - do not force style 8 for hist markers 4. Fix - ensure minimal hist title height 5. Fix - disable Bloom effect on Android +6. Fix - handle reordering of fragments in multipart reply #319 ## Changes in 7.7.4 diff --git a/modules/core.mjs b/modules/core.mjs index 92a5eae1a..1331ac971 100644 --- a/modules/core.mjs +++ b/modules/core.mjs @@ -4,7 +4,7 @@ const version_id = '7.7.x', /** @summary version date * @desc Release date in format day/month/year like '14/04/2022' */ -version_date = '28/10/2024', +version_date = '30/10/2024', /** @summary version id and date * @desc Produced by concatenation of {@link version_id} and {@link version_date}