@@ -27,7 +27,7 @@ export default class DownloadEngineFetchStreamFetch extends BaseDownloadEngineFe
2727 }
2828
2929 protected override async fetchWithoutRetryChunks ( callback : WriteCallback ) {
30- const headers : { [ key : string ] : any } = {
30+ const headers : { [ key : string ] : any ; } = {
3131 accept : "*/*" ,
3232 ...this . options . headers
3333 } ;
@@ -105,13 +105,14 @@ export default class DownloadEngineFetchStreamFetch extends BaseDownloadEngineFe
105105 const fileName = parseContentDisposition ( response . headers . get ( "content-disposition" ) ) ;
106106
107107 let length = parseInt ( response . headers . get ( "content-length" ) ! ) || 0 ;
108- const contentEncoding = response . headers . get ( "content-encoding" ) ;
108+ const someLengthInfo = length ;
109109
110+ const contentEncoding = response . headers . get ( "content-encoding" ) ;
110111 if ( contentEncoding && contentEncoding !== "identity" ) {
111112 length = 0 ; // If content is encoded, we cannot determine the length reliably
112113 }
113114
114- if ( acceptRange && length === 0 && browserCheck ( ) && MIN_LENGTH_FOR_MORE_INFO_REQUEST < length ) {
115+ if ( length === 0 && ( acceptRange || browserCheck ( ) && ( method === "GET" || MIN_LENGTH_FOR_MORE_INFO_REQUEST < someLengthInfo ) ) ) {
115116 length = await this . fetchDownloadInfoWithoutRetryContentRange ( url , method === "GET" ? response : undefined ) ;
116117 }
117118
@@ -194,8 +195,8 @@ export default class DownloadEngineFetchStreamFetch extends BaseDownloadEngineFe
194195 }
195196
196197
197- protected static convertHeadersToRecord ( headers : Headers ) : { [ key : string ] : string } {
198- const headerObj : { [ key : string ] : string } = { } ;
198+ protected static convertHeadersToRecord ( headers : Headers ) : { [ key : string ] : string ; } {
199+ const headerObj : { [ key : string ] : string ; } = { } ;
199200 headers . forEach ( ( value , key ) => {
200201 headerObj [ key ] = value ;
201202 } ) ;
0 commit comments