mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
mm test file
This commit is contained in:
parent
e45bfd66a2
commit
1a7bef0cda
31
ttest.js
31
ttest.js
@ -29,30 +29,25 @@ var srv = http.createServer(function(req, res) {
|
|||||||
res.end('1');
|
res.end('1');
|
||||||
}).listen(8000);
|
}).listen(8000);
|
||||||
|
|
||||||
|
srv.on('connection', function(s) {
|
||||||
|
s.pipe(process.stdout);
|
||||||
|
});
|
||||||
|
|
||||||
srv.on('upgrade', function(req, socket, head) {
|
srv.on('upgrade', function(req, socket, head) {
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
port: 9090,
|
port: 9090,
|
||||||
hostname: '127.0.0.1',
|
hostname: '127.0.0.1',
|
||||||
headers: req.headers
|
headers: req.headers
|
||||||
}
|
}
|
||||||
var req = http.request(options);
|
var r = http.request(options);
|
||||||
req.end();
|
|
||||||
socket.on('data', function(d) {
|
r.on('upgrade', function(res, sock, hd) {
|
||||||
console.log('yoo');
|
if (hd && hd.length) sock.unshift(hd);
|
||||||
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);*/
|
socket.pipe(sock).pipe(socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
r.end();
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user