<commit_before>/* global define, $ */
define(function(require, exports, module) {
    var http_cache = require("../../lib/http_cache");
    
    /**
     * A request wrapper around the jQuery AJAX function.
     * 
     * options:
     * 
     *     headers: {Object}
     *
     *         The HTTP headers
     * 
     *     data: {Object || String} (optional)
     * 
     *          The HTTP request body payload.
     *
     *     type: {String} (optional; default = "Intelligent Guess")
     * 
     *          The type of data expected from the server.
     * 
     * @param {String} verb The HTTP verb (e.g. POST, PUT, etc.)
     * @param {String} url The URL endpoint to which the request should be send.
     * @param {Object} options The jQuery request configuration.
     * @param {Function} callback Node.js style callback.
     * 
     */
    function request(verb, url, options, callback) {
        var args = {};
        
        options = options || {};
        args.url = url;
        args.type = verb;
        args.headers = options.headers;
        args.data = options.data;
        args.dataType = options.dataType;

        $.ajax(args)
            .done(function onDone (data, status, jqXHR) {
                var payload = [
                    data,
                    jqXHR.status,
                    convertResponseHeaders(jqXHR.getAllResponseHeaders())
                ];

                callback(null, payload);
            })
            .fail(function onFail (jqXHR) {
                callback(jqXHR.status)
            });
    }
    
    /**
     * The XHR object returns a string with all response header entries in the form:
     * 
     *     key: "value"
     * 
     * This function converts this string to an object representation.
     * 
     * @param {String} source The headers from the XHR object.
     * 
     * @returns {Object}
     * 
     */
    function convertResponseHeaders(source) {
        var newline = /\r?\n/;
        var headers = {};

        if (!source) {
            return headers;
        }

        source = source.trim();
        source = source.split(newline);

        source.forEach(function onEntry (header) {
            var position = header.indexOf(':');
            var key = header.substr(0, position).toLowerCase();
            var value = header.substr(position + 1).trim();<commit_msg>Removed the lower case transformation.<commit_after>/* global define, $ */
define(function(require, exports, module) {
    var http_cache = require("../../lib/http_cache");
    
    /**
     * A request wrapper around the jQuery AJAX function.
     * 
     * options:
     * 
     *     headers: {Object}
     *
     *         The HTTP headers
     * 
     *     data: {Object || String} (optional)
     * 
     *          The HTTP request body payload.
     *
     *     type: {String} (optional; default = "Intelligent Guess")
     * 
     *          The type of data expected from the server.
     * 
     * @param {String} verb The HTTP verb (e.g. POST, PUT, etc.)
     * @param {String} url The URL endpoint to which the request should be send.
     * @param {Object} options The jQuery request configuration.
     * @param {Function} callback Node.js style callback.
     * 
     */
    function request(verb, url, options, callback) {
        var args = {};
        
        options = options || {};
        args.url = url;
        args.type = verb;
        args.headers = options.headers;
        args.data = options.data;
        args.dataType = options.dataType;

        $.ajax(args)
            .done(function onDone (data, status, jqXHR) {
                var payload = [
                    data,
                    jqXHR.status,
                    convertResponseHeaders(jqXHR.getAllResponseHeaders())
                ];

                callback(null, payload);
            })
            .fail(function onFail (jqXHR) {
                callback(jqXHR.status)
            });
    }
    
    /**
     * The XHR object returns a string with all response header entries in the form:
     * 
     *     key: "value"
     * 
     * This function converts this string to an object representation.
     * 
     * @param {String} source The headers from the XHR object.
     * 
     * @returns {Object}
     * 
     */
    function convertResponseHeaders(source) {
        var newline = /\r?\n/;
        var headers = {};

        if (!source) {
            return headers;
        }

        source = source.trim();
        source = source.split(newline);

        source.forEach(function onEntry (header) {
            var position = header.indexOf(':');
            var key = header.substr(0, position);
            var value = header.substr(position + 1).trim();
{'fraction_non_alphanumeric': 0.11052520565281586, 'fraction_numerical': 0.0008437038599451593, 'mean_word_length': 1.5898416166029492, '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': '4594638', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1259, 'n_words': 369}