<commit_before>var fs = require('fs');
var app = require('express')();
var http = require('http').Server(app);
var https = require('https');
var BinaryServer = require('binaryjs').BinaryServer;
var bs = BinaryServer({server: http});

var currentClient = null;

bs.on('connection', function(client) {
  console.log('Connection to client');
  // this could be improved as right now we only keep one client (browser).
  // Should not be an issue as we only should have one browser connected anyway.
  currentClient = client;
});

app.use(function(req, res){
  if (req.url == '/' ) { // if the request is for '/' we send the index file
    res.sendfile('./public/index.html');
  }
  // otherwise we proxying the request
  else { proxyReq(req, res); }
});

http.addListener('connect', function(req, socket, head) {
  proxyReq(req, socket, head);
});


http.listen(3000, function(){
  console.log('listening on *:3000');
});

// This function acts as a HTTP proxy.
// The request looks something like: GET HTTP://www.google.com
// We pass this on to to our proxy on the internet and they download it for us.
function proxyReq(req, res, head) {
  console.log("Request: " + req.url);

  if (currentClient !== null) {
    var ssl = req.method === 'CONNECT';
    var url = (ssl ? 'https://' : '') + req.url;
    var stream = currentClient.createStream( JSON.stringify({ head: head, url: url, ssl: ssl }) );
    console.log("Created stream for: " + url);
    res.statusCode = 200;

    stream.on('data', function(data) {
      // error handling
      if (data[0] == '{' && data[data.length-1] == '}') {<commit_msg>Fixing index.html path<commit_after>var fs = require('fs');
var app = require('express')();
var http = require('http').Server(app);
var https = require('https');
var BinaryServer = require('binaryjs').BinaryServer;
var bs = BinaryServer({server: http});

var currentClient = null;

bs.on('connection', function(client) {
  console.log('Connection to client');
  // this could be improved as right now we only keep one client (browser).
  // Should not be an issue as we only should have one browser connected anyway.
  currentClient = client;
});

app.use(function(req, res){
  if (req.url == '/' ) { // if the request is for '/' we send the index file
    res.sendfile(__dirname + '/public/index.html');
  }
  // otherwise we proxying the request
  else { proxyReq(req, res); }
});

http.addListener('connect', function(req, socket, head) {
  proxyReq(req, socket, head);
});


http.listen(3000, function(){
  console.log('listening on *:3000');
});

// This function acts as a HTTP proxy.
// The request looks something like: GET HTTP://www.google.com
// We pass this on to to our proxy on the internet and they download it for us.
function proxyReq(req, res, head) {
  console.log("Request: " + req.url);

  if (currentClient !== null) {
    var ssl = req.method === 'CONNECT';
    var url = (ssl ? 'https://' : '') + req.url;
    var stream = currentClient.createStream( JSON.stringify({ head: head, url: url, ssl: ssl }) );
    console.log("Created stream for: " + url);
    res.statusCode = 200;

    stream.on('data', function(data) {
      // error handling
      if (data[0] == '{' && data[data.length-1] == '}') {
{'fraction_non_alphanumeric': 0.1652200867947923, 'fraction_numerical': 0.008059516429014259, 'mean_word_length': 3.670043415340087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3485521', 'n_tokens_mistral': 1015, 'n_tokens_neox': 984, 'n_words': 329}