downloadoptions.js 808 B

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