index.js
function convertToCompressedRequest(req, res, compression) {
        var type = mime.lookup(req.path);
        var charset = mime.charsets.lookup(type);
        var search = req.url.split('?').splice(1).join('?');

        if (search !== "") {
            search = "?" + search;
        }

        req.url = req.path + compression.fileExtension + search;
        res.setHeader("Content-Encoding", compression.encodingName);
        res.setHeader("Content-Type", type + (charset ? "; charset=" + charset : ""));
    }
function convertToCompressedRequest(req, res, compression) {
        var type = mime.lookup(req.path);
        var charset = mime.charsets.lookup(type);
        var search = req.url.split('?').splice(1).join('?');

        if (search !== "") {
            search = "?" + search;
        }

        req.url = req.path + compression.fileExtension + search;
        res.setHeader("Content-Encoding", compression.encodingName);
        res.setHeader("Content-Type", type + (charset ? "; charset=" + charset : ""));
    }
function convertToCompressedRequest ( req , res , compression ) { var type = mime . lookup ( req . path ) ; var charset = mime . charsets . lookup ( type ) ; var search = req . url . split ( '?' ) . splice ( 1 ) . join ( '?' ) ; if ( search !== "" ) { search = "?" + search ; } req . url = req . path + compression . fileExtension + search ; res . setHeader ( "Content-Encoding" , compression . encodingName ) ; res . setHeader ( "Content-Type" , type + ( charset ? "; charset=" + charset : "" ) ) ; }
Changes the url and adds required headers to serve a compressed file.
@param {Object} req
@param {Object} res
Changes the url and adds required headers to serve a compressed file .