index.js
function request(self, options, callback) {
    var _http = get(self, options, 'secure')? https : http;

    if (Steam.devMode) console.log(options);

    var req = _http.request(options, function(res) {
        var data, dataStr = '';

        res.on('data', function (chunk) {
            dataStr += chunk;
        });
        res.on('end', function(){

            var statusCode = res.statusCode;
            if (statusCode !== 200) {

                if (statusCode === 401) {
                    return callback(new Error('Invalid API Key'));
                }
                else {
                    return callback(new Error("HTTP "+statusCode+" "+http.STATUS_CODES[statusCode]));
                }

            }

            // Ensure it is complete and valid JSON
            try {
                data = JSON.parse(dataStr);
            }
            catch (e) {
                return callback(new Error('Unable to parse JSON data'));
            }

            // Trim or simplify data object if it's entirely wrapped in data.response or data.result
            if ((data.response instanceof Object) && (Object.keys(data).length === 1)) {
                data = data.response;
            }
            if ((data.result instanceof Object) && Object.keys(data).length === 1) {
                data = data.result;
            }
            callback(null, data);
        })

    });

    req.end(options.data);

    req.on('error', function(err) {
       callback(err);
    });

}
function request(self, options, callback) {
    var _http = get(self, options, 'secure')? https : http;

    if (Steam.devMode) console.log(options);

    var req = _http.request(options, function(res) {
        var data, dataStr = '';

        res.on('data', function (chunk) {
            dataStr += chunk;
        });
        res.on('end', function(){

            var statusCode = res.statusCode;
            if (statusCode !== 200) {

                if (statusCode === 401) {
                    return callback(new Error('Invalid API Key'));
                }
                else {
                    return callback(new Error("HTTP "+statusCode+" "+http.STATUS_CODES[statusCode]));
                }

            }

            // Ensure it is complete and valid JSON
            try {
                data = JSON.parse(dataStr);
            }
            catch (e) {
                return callback(new Error('Unable to parse JSON data'));
            }

            // Trim or simplify data object if it's entirely wrapped in data.response or data.result
            if ((data.response instanceof Object) && (Object.keys(data).length === 1)) {
                data = data.response;
            }
            if ((data.result instanceof Object) && Object.keys(data).length === 1) {
                data = data.result;
            }
            callback(null, data);
        })

    });

    req.end(options.data);

    req.on('error', function(err) {
       callback(err);
    });

}
Handle the actual HTTP request