index.js 939 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. 'use strict';
  2. const pkg = require('../package.json');
  3. const create = require('./create');
  4. const defaults = {
  5. options: {
  6. retry: {
  7. retries: 2,
  8. methods: [
  9. 'GET',
  10. 'PUT',
  11. 'HEAD',
  12. 'DELETE',
  13. 'OPTIONS',
  14. 'TRACE'
  15. ],
  16. statusCodes: [
  17. 408,
  18. 413,
  19. 429,
  20. 500,
  21. 502,
  22. 503,
  23. 504
  24. ],
  25. errorCodes: [
  26. 'ETIMEDOUT',
  27. 'ECONNRESET',
  28. 'EADDRINUSE',
  29. 'ECONNREFUSED',
  30. 'EPIPE',
  31. 'ENOTFOUND',
  32. 'ENETUNREACH',
  33. 'EAI_AGAIN'
  34. ]
  35. },
  36. headers: {
  37. 'user-agent': `${pkg.name}/${pkg.version} (https://github.com/sindresorhus/got)`
  38. },
  39. hooks: {
  40. beforeRequest: [],
  41. beforeRedirect: [],
  42. beforeRetry: [],
  43. afterResponse: []
  44. },
  45. decompress: true,
  46. throwHttpErrors: true,
  47. followRedirect: true,
  48. stream: false,
  49. form: false,
  50. json: false,
  51. cache: false,
  52. useElectronNet: false
  53. },
  54. mutableDefaults: false
  55. };
  56. const got = create(defaults);
  57. module.exports = got;