Skip to content

Commit 832fdc6

Browse files
committed
Refine fallback solution for servers blocking access to http headers
Such server may process partial http requests but do not allow to read Content-Range header making impossible to parse multipart response. cernbox is one of such servers. Partial reading from such servers is possible - but only 1 segmnent per request. Do not test Accept-Ranges header which not always returned
1 parent 8da3bb0 commit 832fdc6

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

modules/io.mjs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,16 +2782,14 @@ class TFile {
27822782
}
27832783

27842784
if (res && first_req) {
2785-
if (file.fAcceptRanges && !first_req.getResponseHeader('Accept-Ranges')) {
2786-
file.fAcceptRanges = false;
2787-
if (res?.byteLength === place[1]) {
2788-
// special case with cernbox, let try to get full size content
2789-
console.warn(`First block is ${place[1]} bytes but browser does not provides access to header - try to read full file`);
2790-
first_block_retry = true;
2791-
return send_new_request();
2792-
}
2785+
// special workaround for servers like cernbox blocking access to some response headers
2786+
// as result, it is not possible to parse multipart responses
2787+
if (file.fAcceptRanges && (first_req.status === 206) && (res?.byteLength === place[1]) && !first_req.getResponseHeader('Content-Range') && (file.fMaxRanges > 1)) {
2788+
console.warn('Server response with 206 code but browser does not provide access to Content-Range header - setting fMaxRanges = 1, consider to load full file with "filename.root+" argument or adjust server configurations');
2789+
file.fMaxRanges = 1;
27932790
}
27942791

2792+
// workaround for simpleHTTP
27952793
const kind = browser.isFirefox ? first_req.getResponseHeader('Server') : '';
27962794
if (isStr(kind) && kind.indexOf('SimpleHTTP') === 0) {
27972795
file.fMaxRanges = 1;
@@ -2801,7 +2799,6 @@ class TFile {
28012799

28022800
if (res && first_block && !file.fFileContent) {
28032801
// special case - keep content of first request (could be complete file) in memory
2804-
28052802
file.fFileContent = new TBuffer(isStr(res) ? res : new DataView(res));
28062803

28072804
if (!file.fAcceptRanges)

0 commit comments

Comments
 (0)