Created
June 14, 2013 12:43
-
-
Save pasaran/5781516 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Да, тестил тупо через
ab
: