<commit_before>'use strict';

function curl (options, method, path, body) {
    return new Promise((resolve, reject) => {
        const http = require('http'),
            requestOptions = {
                method: method,
                path: path,
                port: options.port,
                hostname: options.host || 'localhost',
                headers: {
                    'Content-Type': 'application/json',
                    Connection: 'close'
                }
            },
            request = http.request(requestOptions, response => {
                response.body = '';
                response.setEncoding('utf8');
                response.on('data', chunk => { response.body += chunk; });
                response.on('end', () => {
                    if (response.statusCode === 200) {
                        response.body = JSON.parse(response.body);
                        resolve(response);
                    }
                    else {
                        reject(new Error(`${response.statusCode}\n${response.body}`));<commit_msg>Send API Key when set<commit_after>'use strict';

function curl (options, method, path, body) {
    return new Promise((resolve, reject) => {
        const http = require('http'),
            requestOptions = {
                method: method,
                path: path,
                port: options.port,
                hostname: options.host || 'localhost',
                headers: {
                    'Content-Type': 'application/json',
                    Connection: 'close'
                }
            };

        if (options.apikey) {
            requestOptions.headers['x-api-key'] = options.apikey;
        }
        
        const request = http.request(requestOptions, response => {
                response.body = '';
                response.setEncoding('utf8');
                response.on('data', chunk => { response.body += chunk; });
                response.on('end', () => {
                    if (response.statusCode === 200) {
                        response.body = JSON.parse(response.body);
                        resolve(response);
                    }
                    else {
                        reject(new Error(`${response.statusCode}\n${response.body}`));
{'fraction_non_alphanumeric': 0.12521968365553604, 'fraction_numerical': 0.0035149384885764497, 'mean_word_length': 1.281563126252505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2304215', 'n_tokens_mistral': 549, 'n_tokens_neox': 507, 'n_words': 106}