http(args.url, opt).then(function (res) { if (opt && opt.headers && opt.headers['X-CSRF-TOKEN']) { if (res.statusCode === 403 && (res.statusMessage === 'XSRF Token Validation Failed' || res.statusMessage === 'Token Validation Failed')) { depth++ if (depth >= 3) { throw new Error('Tried ' + depth + ' times and could not refresh XCSRF token successfully') } const token = res.headers['x-csrf-token'] if (token) { opt.headers['X-CSRF-TOKEN'] = token opt.jar = jar args.depth = depth + 1 return exports.func(args) } else { throw new Error('Could not refresh X-CSRF-TOKEN') } } else { if (depth > 0) { cache.add(options.cache, 'XCSRF', getHash({ jar: jar }), opt.headers['X-CSRF-TOKEN']) } } } if (res.statusCode === 302 && !args.ignoreLoginError && res.headers.location && (res.headers.location.startsWith('https://www.roblox.com/newlogin') || res.headers.location.startsWith('/Login/Default.aspx'))) { throw new Error('You are not logged in') } return full ? res : res.body })