lib/ponse.js
function sendFile(params) {
    const p = params;
    
    checkParams(params);
    
    fs.lstat(p.name, (error, stat) => {
        if (error)
            return sendError(error, params);
        
        const isGzip = isGZIP(p.request) && p.gzip;
        const time = stat.mtime.toUTCString();
        const length = stat.size;
        const range = getRange(p.request, length);
        
        if (range)
            assign(p, {
                range,
                status: RANGE
            });
        
        assign(p, {
            time
        });
        
        if (!isGzip)
            p.length = length;
        
        setHeader(params);
        
        const options = {
            gzip    : isGzip,
            range,
        };
        
        files.pipe(p.name, p.response, options).catch((error) => {
            sendError(error, params);
        });
    });
}
function sendFile(params) {
    const p = params;
    
    checkParams(params);
    
    fs.lstat(p.name, (error, stat) => {
        if (error)
            return sendError(error, params);
        
        const isGzip = isGZIP(p.request) && p.gzip;
        const time = stat.mtime.toUTCString();
        const length = stat.size;
        const range = getRange(p.request, length);
        
        if (range)
            assign(p, {
                range,
                status: RANGE
            });
        
        assign(p, {
            time
        });
        
        if (!isGzip)
            p.length = length;
        
        setHeader(params);
        
        const options = {
            gzip    : isGzip,
            range,
        };
        
        files.pipe(p.name, p.response, options).catch((error) => {
            sendError(error, params);
        });
    });
}
function sendFile ( params ) { const p = params ; checkParams ( params ) ; fs . lstat ( p . name , ( error , stat ) => { if ( error ) return sendError ( error , params ) ; const isGzip = isGZIP ( p . request ) && p . gzip ; const time = stat . mtime . toUTCString ( ) ; const length = stat . size ; const range = getRange ( p . request , length ) ; if ( range ) assign ( p , { range , status : RANGE } ) ; assign ( p , { time } ) ; if ( ! isGzip ) p . length = length ; setHeader ( params ) ; const options = { gzip : isGzip , range , } ; files . pipe ( p . name , p . response , options ) . catch ( ( error ) => { sendError ( error , params ) ; } ) ; } ) ; }
send file to client thru pipe
and gzip it if client support
send file to client thru pipe and gzip it if client support