downloadoptions.js 716 B

123456789101112131415161718192021222324252627282930
  1. var proxy = require('./proxy'),
  2. userAgent = require('./useragent');
  3. /**
  4. * The options passed to request when downloading the bibary
  5. *
  6. * There some nuance to how request handles options. Specifically
  7. * we've been caught by their usage of `hasOwnProperty` rather than
  8. * falsey checks. By moving the options generation into a util helper
  9. * we can test for regressions.
  10. *
  11. * @return {Object} an options object for request
  12. * @api private
  13. */
  14. module.exports = function() {
  15. var options = {
  16. rejectUnauthorized: false,
  17. timeout: 60000,
  18. headers: {
  19. 'User-Agent': userAgent(),
  20. }
  21. };
  22. var proxyConfig = proxy();
  23. if (proxyConfig) {
  24. options.proxy = proxyConfig;
  25. }
  26. return options;
  27. };