Skip to content

Commit

Permalink
mm test file
Browse files Browse the repository at this point in the history
  • Loading branch information
yawnt committed Sep 14, 2013
1 parent e45bfd6 commit 1a7bef0
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions ttest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
socket.write(hd);
socket.pipe(sock).pipe(socket);*/
var r = http.request(options);

r.on('upgrade', function(res, sock, hd) {
if (hd && hd.length) sock.unshift(hd);


socket.pipe(sock).pipe(socket);
});

r.end();
});

0 comments on commit 1a7bef0

Please sign in to comment.