<commit_before>'use strict';

const http = require('http');
const https = require('https');

const defaults = require('./defaults');
const externalRequest = require('./external-request');

// callback(err, protocol)
module.exports.Protocol = promisesWrapper(function (options, callback) {
    // if the local protocol is requested
    if (!options.remote) {
        const localDescriptor = require('./protocol.json');
        callback(null, {
            'remote': false,
            'descriptor': localDescriptor
        });
        return;
    }
    // try to fecth the browser version information and the protocol (remotely)
    module.exports.Version(options, function (err, info) {
        if (err) {
            callback(err);
            return;
        }
        // fetch the reported browser info (Node.js returns an array)
        const browser = (info[0] || info).Browser;
        // use the proper protocol fetcher
        let fetcher;
        if (browser.match(/^Chrome\//)) {
            fetcher = fetchFromChromeRepo;
        } else if (browser.match(/^Microsoft Edge /)) {
            fetcher = fetchFromHttpEndpoint;
        } else if (browser.match(/^node.js\//)) {
            fetcher = fetchFromHttpEndpoint;
        } else {
            callback(new Error('Unknown implementation'));
            return;
        }
        fetcher(options, info, function (err, descriptor) {<commit_msg>Explicitly include the Chrome headless product string<commit_after>'use strict';

const http = require('http');
const https = require('https');

const defaults = require('./defaults');
const externalRequest = require('./external-request');

// callback(err, protocol)
module.exports.Protocol = promisesWrapper(function (options, callback) {
    // if the local protocol is requested
    if (!options.remote) {
        const localDescriptor = require('./protocol.json');
        callback(null, {
            'remote': false,
            'descriptor': localDescriptor
        });
        return;
    }
    // try to fecth the browser version information and the protocol (remotely)
    module.exports.Version(options, function (err, info) {
        if (err) {
            callback(err);
            return;
        }
        // fetch the reported browser info (Node.js returns an array)
        const browser = (info[0] || info).Browser;
        // use the proper protocol fetcher
        let fetcher;
        if (browser.match(/^(Headless)?Chrome\//)) {
            fetcher = fetchFromChromeRepo;
        } else if (browser.match(/^Microsoft Edge /)) {
            fetcher = fetchFromHttpEndpoint;
        } else if (browser.match(/^node.js\//)) {
            fetcher = fetchFromHttpEndpoint;
        } else {
            callback(new Error('Unknown implementation'));
            return;
        }
        fetcher(options, info, function (err, descriptor) {
{'fraction_non_alphanumeric': 0.1225986727209221, 'fraction_numerical': 0.0006985679357317499, 'mean_word_length': 2.288174512055109, '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': '569736', 'n_tokens_mistral': 726, 'n_tokens_neox': 730, 'n_words': 208}