lib/request.js
function read(uri) {
    "use strict";
    var parsedUrl = url.parse(uri, false, true);
    var makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http);
    var serverPort = parsedUrl.port ? parsedUrl.port : parsedUrl.protocol === 'https:' ? 443 : 80;
    var agent = parsedUrl.protocol === 'https:' ? httpsAgent : httpAgent;

    var options = {
        host: parsedUrl.host,
        path: parsedUrl.path,
        agent: agent,
        port: serverPort,
        method: 'GET',
        headers: {'Content-Type': 'application/json'}
    };

    return new Promise(function (resolve, reject) {

        var req = makeRequest(options, function (response) {
            var data = '';

            response.on('data', function (chunk) {
                data += chunk;
            });

            response.on('end', function () {
                resolve({
                    status: response.statusCode,
                    data: data
                });
            });
        });

        req.on('error', reject);
        req.end();
    });
}
function read(uri) {
    "use strict";
    var parsedUrl = url.parse(uri, false, true);
    var makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http);
    var serverPort = parsedUrl.port ? parsedUrl.port : parsedUrl.protocol === 'https:' ? 443 : 80;
    var agent = parsedUrl.protocol === 'https:' ? httpsAgent : httpAgent;

    var options = {
        host: parsedUrl.host,
        path: parsedUrl.path,
        agent: agent,
        port: serverPort,
        method: 'GET',
        headers: {'Content-Type': 'application/json'}
    };

    return new Promise(function (resolve, reject) {

        var req = makeRequest(options, function (response) {
            var data = '';

            response.on('data', function (chunk) {
                data += chunk;
            });

            response.on('end', function () {
                resolve({
                    status: response.statusCode,
                    data: data
                });
            });
        });

        req.on('error', reject);
        req.end();
    });
}
function read ( uri ) { "use strict" ; var parsedUrl = url . parse ( uri , false , true ) ; var makeRequest = parsedUrl . protocol === 'https:' ? https . request . bind ( https ) : http . request . bind ( http ) ; var serverPort = parsedUrl . port ? parsedUrl . port : parsedUrl . protocol === 'https:' ? 443 : 80 ; var agent = parsedUrl . protocol === 'https:' ? httpsAgent : httpAgent ; var options = { host : parsedUrl . host , path : parsedUrl . path , agent : agent , port : serverPort , method : 'GET' , headers : { 'Content-Type' : 'application/json' } } ; return new Promise ( function ( resolve , reject ) { var req = makeRequest ( options , function ( response ) { var data = '' ; response . on ( 'data' , function ( chunk ) { data += chunk ; } ) ; response . on ( 'end' , function ( ) { resolve ( { status : response . statusCode , data : data } ) ; } ) ; } ) ; req . on ( 'error' , reject ) ; req . end ( ) ; } ) ; }
Reads the contents of a url as a string.

@param uri {string} the url to read
@returns {Promise.<string>} the url contents
Reads the contents of a url as a string .