proxy-gremlin
Advanced tools
Comparing version 0.2.1 to 0.2.2
14
index.js
@@ -58,17 +58,16 @@ var util = require('util') | ||
exports.intercept = function(res, interceptor) { | ||
exports.intercept = function intercept(res, interceptor) { | ||
// save the original response method | ||
// Save the original response method; | ||
// buffer will monkey patch the response. | ||
var end = res.end | ||
, writeHead = res.writeHead | ||
, buffer = new Buffer(res) | ||
// Buffer monkey patches the response | ||
var buffer = new Buffer(res) | ||
res.on('end', function onResEnd() { | ||
// apply outgoing transformations on the buffered response | ||
// Apply outgoing transformations on the buffered response. | ||
interceptor(buffer) | ||
// send the response to the client | ||
// Send the response to the client. | ||
writeHead.call(res, buffer.statusCode, buffer.headers) | ||
@@ -78,1 +77,2 @@ end.call(res, buffer.getData(), buffer.encoding) | ||
} | ||
{ | ||
"name": "proxy-gremlin", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"author": "omphalos", | ||
@@ -5,0 +5,0 @@ "description": "Utility to assist in changing proxied requests.", |
4701