examples/helpers.js
function sendModifiedResponse(clientRes, response, transform) {
    var dataPipe = response,
        decompressor = decompressorFor(response),
        chunks = [];

    if(decompressor) {
        dataPipe = dataPipe.pipe(decompressor);
    }
    dataPipe.on('data', function(chunk) {
        chunks.push(chunk);
    });
    dataPipe.on('end', function () {
        var origContent = Buffer.concat(chunks);
        transform(origContent, function (modifiedContent) {
            response.headers['content-length'] = modifiedContent.length;
            // The response has been de-chunked and uncompressed, so delete
            // these headers from the response.
            delete response.headers['content-encoding'];
            delete response.headers['content-transfer-encoding'];
            clientRes.writeHead(response.statusCode, response.headers);
            clientRes.end(modifiedContent);
        });
    });
}
function sendModifiedResponse(clientRes, response, transform) {
    var dataPipe = response,
        decompressor = decompressorFor(response),
        chunks = [];

    if(decompressor) {
        dataPipe = dataPipe.pipe(decompressor);
    }
    dataPipe.on('data', function(chunk) {
        chunks.push(chunk);
    });
    dataPipe.on('end', function () {
        var origContent = Buffer.concat(chunks);
        transform(origContent, function (modifiedContent) {
            response.headers['content-length'] = modifiedContent.length;
            // The response has been de-chunked and uncompressed, so delete
            // these headers from the response.
            delete response.headers['content-encoding'];
            delete response.headers['content-transfer-encoding'];
            clientRes.writeHead(response.statusCode, response.headers);
            clientRes.end(modifiedContent);
        });
    });
}
function sendModifiedResponse ( clientRes , response , transform ) { var dataPipe = response , decompressor = decompressorFor ( response ) , chunks = [ ] ; if ( decompressor ) { dataPipe = dataPipe . pipe ( decompressor ) ; } dataPipe . on ( 'data' , function ( chunk ) { chunks . push ( chunk ) ; } ) ; dataPipe . on ( 'end' , function ( ) { var origContent = Buffer . concat ( chunks ) ; transform ( origContent , function ( modifiedContent ) { response . headers [ 'content-length' ] = modifiedContent . length ; // The response has been de-chunked and uncompressed, so delete // these headers from the response. delete response . headers [ 'content-encoding' ] ; delete response . headers [ 'content-transfer-encoding' ] ; clientRes . writeHead ( response . statusCode , response . headers ) ; clientRes . end ( modifiedContent ) ; } ) ; } ) ; }
Transform the server's response and send it to the proxy client.

@param {http.ServerResponse} clientRes - Response to the client.
@param {http.IncomingMessage} response - Response from the server.
@param {transformCallback} transform - How to transform the server's response.
Transform the server s response and send it to the proxy client .