From 17e750bbe37085ad43aba120b0dea792c2ff5cb4 Mon Sep 17 00:00:00 2001 From: Krisztian Nagy <13612429+mxsxs2@users.noreply.github.com> Date: Wed, 16 Nov 2022 11:52:54 +0000 Subject: [PATCH 1/2] Add X-File-Size header support to FileLoader --- src/loaders/FileLoader.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/loaders/FileLoader.js b/src/loaders/FileLoader.js index bfcb6e1a63cf9b..86d1768d6bfe92 100644 --- a/src/loaders/FileLoader.js +++ b/src/loaders/FileLoader.js @@ -109,7 +109,8 @@ class FileLoader extends Loader { const callbacks = loading[ url ]; const reader = response.body.getReader(); - const contentLength = response.headers.get( 'Content-Length' ); + // Extra header added because of: https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content + const contentLength = response.headers.get( 'Content-Length' ) || response.headers.get( 'X-File-Size' ); const total = contentLength ? parseInt( contentLength ) : 0; const lengthComputable = total !== 0; let loaded = 0; From 51bfe6acc862050ec0c24cae40fc061c20583e63 Mon Sep 17 00:00:00 2001 From: mrdoob Date: Thu, 17 Nov 2022 01:17:11 -0800 Subject: [PATCH 2/2] Update FileLoader.js --- src/loaders/FileLoader.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/loaders/FileLoader.js b/src/loaders/FileLoader.js index 86d1768d6bfe92..1e528eb11fb19b 100644 --- a/src/loaders/FileLoader.js +++ b/src/loaders/FileLoader.js @@ -109,7 +109,9 @@ class FileLoader extends Loader { const callbacks = loading[ url ]; const reader = response.body.getReader(); - // Extra header added because of: https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content + + // Nginx needs X-File-Size check + // https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content const contentLength = response.headers.get( 'Content-Length' ) || response.headers.get( 'X-File-Size' ); const total = contentLength ? parseInt( contentLength ) : 0; const lengthComputable = total !== 0;