// Dependencies
var request = require('request-promise').defaults({
  pool: {maxSockets: Infinity},
  resolveWithFullResponse: true,
  simple: false // Simpler is more complicated!
});

// Includes
var options = require('../options.js');

// Args
exports.args = ['url', 'options'];

// Define

function http (url, opt) {
  if (opt && !opt.jar && Object.keys(opt).indexOf('jar') > -1) {
    opt.jar = options.jar;
  }
  if (options.sessionOnly && opt.jar) {
    opt.headers.cookie = '.ROBLOSECURITY=' + opt.jar.session + ';';
  }
  if (url.indexOf('http') !== 0) {
    url = 'https:' + url;
  }
  return request(url, opt).then(function (res) {
    var session = res.headers['set-cookie'].match('\.ROBLOSECURITY=(.*);');
    if (session) {
      opt.jar.session = session;
    }
    if (opt.resolveWithFullResponse === true) {
      return res;
    } else {
      return res.body;
    }
  });
}

exports.func = function (args) {
  var promise = http(args.url, args.options);
  var handler = options.errorHandler;
  if (handler) {
    return promise.catch(options.errorHandler);
  } else {
    return promise;
  }
};

@@ -95,16 +95,18 @@
 ity%7D,%0A  
+//
 resolveW
@@ -128,16 +128,16 @@
 : true,%0A
-
   simple
@@ -288,17 +288,16 @@
  Define%0A
-%0A
 function
@@ -447,24 +447,78 @@
  opt.jar) %7B%0A
+    if (!opt.headers) %7B%0A      opt.headers = %7B%7D;%0A    %7D%0A
     opt.head
@@ -642,16 +642,16 @@
 rl;%0A  %7D%0A
+
   return
@@ -672,277 +672,8 @@
 opt)
-.then(function (res) %7B%0A    var session = res.headers%5B'set-cookie'%5D.match('%5C.ROBLOSECURITY=(.*);');%0A    if (session) %7B%0A      opt.jar.session = session;%0A    %7D%0A    if (opt.resolveWithFullResponse === true) %7B%0A      return res;%0A    %7D else %7B%0A      return res.body;%0A    %7D%0A  %7D)
 ;%0A%7D%0A

Fix cookies