UNPKG

all-node-oracle

Version:

A NodeJS and Oracle DB integration, NodeJS act as http gateway for plsql server pages

37 lines (34 loc) 825 B
/** * Created with JetBrains WebStorm. * User: kaven276 * Date: 12-6-17 * Time: 下午2:42 */ var crypto = require('crypto') , createHash = crypto.createHash , EE = require('events').EventEmitter ; module.exports = function MD5CalcFilter(oraRes, ohdr, flags){ if (ohdr['Content-MD5'] === '?') ; else { return oraRes; } var chunks = [] , count = 0 , hash = createHash('md5') , ee = new EE() ; oraRes.on('data', function(data){ if (!data) return true; chunks.push(data); count += data.length; hash.update(data, 'binary'); }); oraRes.on('end', function(){ delete ohdr['Transfer-Encoding']; ohdr['Content-Length'] = count.toString(); ohdr['Content-MD5'] = hash.digest('base64'); ee.emit('end', chunks); }); flags.headFixed = false; return ee; };