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

var noop = function() {};
module.exports = function(uri, method, options) {
    if(typeof method === 'undefined') {
        method = 'GET';
        options = {};
    } else if(typeof options === 'undefined') {
        if(typeof method === 'string') {
            options = {};
        } else {
            options = method;
            method = 'GET';
        }
    }
    options = options || {};
    var uploadProgressCb = options.uploading || noop;
    var downloadProgressCb = options.downloading || noop;
    var statusCb = options.gotStatus || noop;
    var cb = options.finished || noop;
    var deleteCallbacks = function() {
        uploadProgressCb = null;
        downloadProgressCb = null;
        statusCb = null;
        cb = null;
    };
    var input = options.input || null, inputLength = input === null ? 0 : input.length, inputHeaders = options.headers || [];
    var output, outputLength, outputHeaders = {};

    uri = url.parse(uri);
    var req = http.request({
        hostname: uri.hostname,
        port: Number(uri.port),
        path: uri.path,
        method: method
    }, function(res) {
        if(cb) {
            var output = '';
            res.setEncoding('utf8');
            res.on('data', function(chunk) {
                output += chunk;
            });
            res.on('end', function() {
                if(cb) {
                    cb(null, output);
                }
            });
        }
    });

    if(input !== null) {
        req.write(input);
    }
    req.on('error', function(e) {
        cb(e);
        deleteCallbacks();
    });
    req.end();
};
<commit_msg>-node: implement options.gotStatus<commit_after>var http = require('http');
var url = require('url');

var noop = function() {};
module.exports = function(uri, method, options) {
    if(typeof method === 'undefined') {
        method = 'GET';
        options = {};
    } else if(typeof options === 'undefined') {
        if(typeof method === 'string') {
            options = {};
        } else {
            options = method;
            method = 'GET';
        }
    }
    options = options || {};
    var uploadProgressCb = options.uploading || noop;
    var downloadProgressCb = options.downloading || noop;
    var statusCb = options.gotStatus || noop;
    var cb = options.finished || noop;
    var deleteCallbacks = function() {
        uploadProgressCb = null;
        downloadProgressCb = null;
        statusCb = null;
        cb = null;
    };
    var input = options.input || null, inputLength = input === null ? 0 : input.length, inputHeaders = options.headers || [];
    var output, outputLength, outputHeaders = {};

    uri = url.parse(uri);
    var req = http.request({
        hostname: uri.hostname,
        port: Number(uri.port),
        path: uri.path,
        method: method
    }, function(res) {
        if(statusCb) {
            statusCb(res.statusCode, res.headers);
            statusCb = null;
        }
        if(cb) {
            var output = '';
            res.setEncoding('utf8');
            res.on('data', function(chunk) {
                output += chunk;
            });
            res.on('end', function() {
                if(cb) {
                    cb(null, output);
                }
            });
        }
    });

    if(input !== null) {
        req.write(input);
    }
    req.on('error', function(e) {
        cb(e);
        deleteCallbacks();
    });
    req.end();
};

{'fraction_non_alphanumeric': 0.14704209328782708, 'fraction_numerical': 0.0011376564277588168, 'mean_word_length': 1.7498045347928068, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2803073', 'n_tokens_mistral': 1009, 'n_tokens_neox': 995, 'n_words': 229}