<commit_before>var caronte = require('./'),
    http    = require('http'),
    ws      = require('ws');
  
var proxyTo = new ws.Server({ port: 9090 });

proxyTo.on('connection', function(ws) {
  console.log('connection!');
  ws.on('message', function(msg) {
    console.log('received: ' + msg);
  });
  ws.send('derpity?');
});

/*caronte.createProxyServer({
  ws    : true,
  target: 'http://127.0.0.1:9090'
}).listen(8000);*/


var client = new ws('ws://127.0.0.1:8000');
client.on('open', function() {
  client.send('baaaka');
  console.log('sent: baaaaka');
});


var srv = http.createServer(function(req, res) {
  res.end('1');
}).listen(8000);

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);*/
  });
});<commit_msg>mm test file<commit_after>var caronte = require('./'),
    http    = require('http'),
    ws      = require('ws');
  
var proxyTo = new ws.Server({ port: 9090 });

proxyTo.on('connection', function(ws) {
  console.log('connection!');
  ws.on('message', function(msg) {
    console.log('received: ' + msg);
  });
  ws.send('derpity?');
});

/*caronte.createProxyServer({
  ws    : true,
  target: 'http://127.0.0.1:9090'
}).listen(8000);*/


var client = new ws('ws://127.0.0.1:8000');
client.on('open', function() {
  client.send('baaaka');
  console.log('sent: baaaaka');
});


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 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();
});
{'fraction_non_alphanumeric': 0.22744439781787662, 'fraction_numerical': 0.03860679815358791, 'mean_word_length': 3.3503649635036497, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7258349', 'n_tokens_mistral': 978, 'n_tokens_neox': 898, 'n_words': 159}