Skip to content

Instantly share code, notes, and snippets.

@zapu
Created August 24, 2011 17:35
Show Gist options
  • Save zapu/1168628 to your computer and use it in GitHub Desktop.
Save zapu/1168628 to your computer and use it in GitHub Desktop.
proxyResponse.addListener('end', function(e) {
var bufferSize = 0;
chunks.forEach(function(chunk) {
bufferSize += chunk.length;
});
var buffer = new Buffer(bufferSize);
var pos = 0;
chunks.forEach(function(chunk) {
chunk.copy(buffer, pos, 0);
pos += chunk.length;
});
response.writeHead(proxyResponse.statusCode, proxyResponse.headers);
response.write(buffer);
response.end();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment