Sha256: e7033abac8962a60c32f802dea20c2594adddad55f9ec792731d66e673c40b44

Contents?: true

Size: 718 Bytes

Versions: 1

Compression:

Stored size: 718 Bytes

Contents

'use strict';

const REQUEST_TIMEOUT = 10000;

// callback(err, data)
function externalRequest(transport, options, callback) {
    const request = transport.get(options, function (response) {
        let data = '';
        response.on('data', function (chunk) {
            data += chunk;
        });
        response.on('end', function () {
            if (response.statusCode === 200) {
                callback(null, data);
            } else {
                callback(new Error(data));
            }
        });
    });
    request.setTimeout(REQUEST_TIMEOUT, function () {
        this.abort();
    });
    request.on('error', function (err) {
        callback(err);
    });
}

module.exports = externalRequest;

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dragonfly_chrome_headless-0.2.0 node_modules/chrome-remote-interface/lib/external-request.js