@@ -8,9 +8,10 @@ import { UploadService } from '../../services/network/upload.service';
88import { DownloadService } from '../../services/network/download.service' ;
99import { CryptoService } from '../../services/crypto.service' ;
1010import { AuthService } from '../../services/auth.service' ;
11- import { NotFoundError , NotImplementedError } from '../../utils/errors.utils' ;
11+ import { NotFoundError } from '../../utils/errors.utils' ;
1212import { webdavLogger } from '../../utils/logger.utils' ;
1313import { DriveFileItem } from '../../types/drive.types' ;
14+ import { NetworkUtils } from '../../utils/network.utils' ;
1415
1516export class GETRequestHandler implements WebDavMethodHandler {
1617 constructor (
@@ -29,8 +30,6 @@ export class GETRequestHandler implements WebDavMethodHandler {
2930 const { driveDatabaseManager, driveFileService, authService, networkFacade } = this . dependencies ;
3031 const resource = await WebDavUtils . getRequestedResource ( req ) ;
3132
32- if ( req . headers [ 'content-range' ] || req . headers [ 'range' ] )
33- throw new NotImplementedError ( 'Range requests not supported' ) ;
3433 if ( resource . name . startsWith ( '._' ) ) throw new NotFoundError ( 'File not found' ) ;
3534
3635 webdavLogger . info ( `GET request received for file at ${ resource . url } ` ) ;
@@ -42,9 +41,6 @@ export class GETRequestHandler implements WebDavMethodHandler {
4241
4342 webdavLogger . info ( `✅ Found Drive File with uuid ${ driveFile . uuid } ` ) ;
4443
45- res . set ( 'Content-Type' , 'application/octet-stream' ) ;
46- res . set ( 'Content-length' , driveFile . size . toString ( ) ) ;
47-
4844 const { user } = await authService . getAuthDetails ( ) ;
4945 webdavLogger . info ( '✅ Network ready for download' ) ;
5046
@@ -57,12 +53,27 @@ export class GETRequestHandler implements WebDavMethodHandler {
5753 } ,
5854 } ) ;
5955
56+ const range = req . headers [ 'range' ] ;
57+ const rangeOptions = NetworkUtils . parseRangeHeader ( {
58+ range,
59+ totalFileSize : driveFile . size ,
60+ } ) ;
61+ let contentLength = driveFile . size ;
62+ if ( rangeOptions ) {
63+ webdavLogger . info ( '✅ Range request received:' , { rangeOptions } ) ;
64+ contentLength = rangeOptions . rangeSize ;
65+ }
66+
67+ res . set ( 'Content-Type' , 'application/octet-stream' ) ;
68+ res . set ( 'Content-length' , contentLength . toString ( ) ) ;
69+
6070 let lastLoggedProgress = 0 ;
6171 const [ executeDownload ] = await networkFacade . downloadToStream (
6272 driveFile . bucket ,
6373 user . mnemonic ,
6474 driveFile . fileId ,
6575 writable ,
76+ rangeOptions ,
6677 {
6778 progressCallback : ( progress ) => {
6879 const percentage = Math . floor ( 100 * progress ) ;
0 commit comments