downloadoptions.js 737 B

12345678910111213141516171819202122232425262728293031
  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. encoding: null,
  22. };
  23. var proxyConfig = proxy();
  24. if (proxyConfig) {
  25. options.proxy = proxyConfig;
  26. }
  27. return options;
  28. };