mm test file

This commit is contained in:
yawnt 2013-09-14 10:06:03 +02:00
parent e45bfd66a2
commit 1a7bef0cda

View File

@ -29,30 +29,25 @@ var srv = http.createServer(function(req, res) {
res.end('1');
}).listen(8000);
srv.on('connection', function(s) {
s.pipe(process.stdout);
});
srv.on('upgrade', function(req, socket, head) {
var options = {
port: 9090,
hostname: '127.0.0.1',
headers: req.headers
}
var req = http.request(options);
req.end();
socket.on('data', function(d) {
console.log('yoo');
console.log(d);
});
var s;
req.on('socket', function(ss) {
s = ss;
});
req.on('upgrade', function(res, sock, hd) {
/*console.log(hd.toString('utf-8'));
var str = Object.keys(res.headers).map(function(i) {
return i + ": " + res.headers[i];
}).join('\r\n');
socket.write("HTTP/1.1 101 Switching Protocols\r\n" + str);
var r = http.request(options);
r.on('upgrade', function(res, sock, hd) {
if (hd && hd.length) sock.unshift(hd);
socket.write(hd);
socket.pipe(sock).pipe(socket);*/
socket.pipe(sock).pipe(socket);
});
r.end();
});