<commit_before>var url = require('url');
var http = require('http');
var fs = require('fs');
var mime = require('mime');

function serveStaticFile(filePath, res, cb, opts) {
    opts = opts || {};
    var fsObject   = opts.fs   || fs;
    var mimeObject = opts.mime || mime;

    fsObject.readFile(filePath, function(err, data) {
        if (err) {
            res.statusCode = 404;
            res.send("Not Found");
        } else {
            res.contentType(mimeObject.lookup(filePath));
            res.send(data);
        }
        cb();
    });
}

function proxyRequest(req, res, proxyTo, cb, opts) {
    var httpCreateClientFunction = opts.httpCreateClientFunction ||
        http.createClient;

    var proxyUrl = proxyTo;
    if (typeof(proxyTo) === 'string') {
        proxyUrl = url.parse(proxyTo);
    }
    var proxyToHost = proxyUrl.host;
    var proxyToPort = proxyUrl.port ||
        (proxyUrl.protocol === 'https:' ? 443 : 80);
    var proxyToPath = proxyUrl.pathname;

    var proxy = httpCreateClientFunction(proxyToPort, proxyToHost),
    proxy_req = proxy.request(req.method, proxyToPath, req.headers);

    proxy.on('error', function (err) {
        res.writeHead(502);
        res.write('Bad Gateway! Could not proxy request. Invalid host or proxy destination down?');
        res.end();
    });

    proxy_req.addListener("response", function (proxy_res) {
        // Copy over headers and status code from proxied request
        res.writeHead(
            proxy_res.statusCode,
            proxy_res.headers
        );
<commit_msg>Make proxyRequest work without options<commit_after>var url = require('url');
var http = require('http');
var fs = require('fs');
var mime = require('mime');

function serveStaticFile(filePath, res, cb, opts) {
    opts = opts || {};
    var fsObject   = opts.fs   || fs;
    var mimeObject = opts.mime || mime;

    fsObject.readFile(filePath, function(err, data) {
        if (err) {
            res.statusCode = 404;
            res.send("Not Found");
        } else {
            res.contentType(mimeObject.lookup(filePath));
            res.send(data);
        }
        cb();
    });
}

function proxyRequest(req, res, proxyTo, cb, opts) {
    opts = opts || {};
    var httpCreateClientFunction = opts.httpCreateClientFunction ||
        http.createClient;

    var proxyUrl = proxyTo;
    if (typeof(proxyTo) === 'string') {
        proxyUrl = url.parse(proxyTo);
    }
    var proxyToHost = proxyUrl.host;
    var proxyToPort = proxyUrl.port ||
        (proxyUrl.protocol === 'https:' ? 443 : 80);
    var proxyToPath = proxyUrl.pathname;

    var proxy = httpCreateClientFunction(proxyToPort, proxyToHost),
    proxy_req = proxy.request(req.method, proxyToPath, req.headers);

    proxy.on('error', function (err) {
        res.writeHead(502);
        res.write('Bad Gateway! Could not proxy request. Invalid host or proxy destination down?');
        res.end();
    });

    proxy_req.addListener("response", function (proxy_res) {
        // Copy over headers and status code from proxied request
        res.writeHead(
            proxy_res.statusCode,
            proxy_res.headers
        );

{'fraction_non_alphanumeric': 0.12886923562855337, 'fraction_numerical': 0.006948831332912192, 'mean_word_length': 2.5664414414414414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '760534', 'n_tokens_mistral': 967, 'n_tokens_neox': 926, 'n_words': 228}