Skip to content

Instantly share code, notes, and snippets.

@pasaran
Created June 14, 2013 12:43
Show Gist options
  • Save pasaran/5781516 to your computer and use it in GitHub Desktop.
Save pasaran/5781516 to your computer and use it in GitHub Desktop.
var http = require('http');
var data = [];
var length;
var req = http.request('http://mail.yandex.ru', function(res) {
res.on('data', function (chunk) {
data.push(chunk);
});
res.on('end', function() {
length = data.length;
startServer();
});
});
req.end();
function startServer() {
http.createServer(function(req, res) {
res.writeHead( 200, { 'Content-Type': 'text/html' } );
for (var i = 0; i < length; i++) {
res.write( data[i] );
}
res.end();
}).listen(9000, '127.0.0.1');
}
var http = require('http');
var length = 0;
var data = [];
var buffer;
var req = http.request('http://mail.yandex.ru', function(res) {
res.on('data', function (chunk) {
length += chunk.length;
data.push(chunk);
});
res.on('end', function() {
buffer = Buffer.concat(data, length);
startServer();
});
});
req.end();
function startServer() {
http.createServer(function(req, res) {
res.writeHead( 200, { 'Content-Type': 'text/html' } );
res.end(buffer);
}).listen(9000, '127.0.0.1');
}
var http = require('http');
var result = '';
var req = http.request('http://mail.yandex.ru', function(res) {
res.on('data', function (chunk) {
result += chunk;
});
res.on('end', startServer);
});
req.end();
function startServer() {
http.createServer(function(req, res) {
res.writeHead( 200, { 'Content-Type': 'text/html' } );
res.end(result);
}).listen(9000, '127.0.0.1');
}
@pasaran
Copy link
Author

pasaran commented Jun 14, 2013

Да, тестил тупо через ab:

ab -n 10000 -c 100 http://127.0.0.1:9000/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment