123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- "use strict";
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
- }) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- }));
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- const url_1 = require("url");
- const create_1 = require("./create");
- const defaults = {
- options: {
- method: 'GET',
- retry: {
- limit: 2,
- methods: [
- 'GET',
- 'PUT',
- 'HEAD',
- 'DELETE',
- 'OPTIONS',
- 'TRACE'
- ],
- statusCodes: [
- 408,
- 413,
- 429,
- 500,
- 502,
- 503,
- 504,
- 521,
- 522,
- 524
- ],
- errorCodes: [
- 'ETIMEDOUT',
- 'ECONNRESET',
- 'EADDRINUSE',
- 'ECONNREFUSED',
- 'EPIPE',
- 'ENOTFOUND',
- 'ENETUNREACH',
- 'EAI_AGAIN'
- ],
- maxRetryAfter: undefined,
- calculateDelay: ({ computedValue }) => computedValue
- },
- timeout: {},
- headers: {
- 'user-agent': 'got (https://github.com/sindresorhus/got)'
- },
- hooks: {
- init: [],
- beforeRequest: [],
- beforeRedirect: [],
- beforeRetry: [],
- beforeError: [],
- afterResponse: []
- },
- cache: undefined,
- dnsCache: undefined,
- decompress: true,
- throwHttpErrors: true,
- followRedirect: true,
- isStream: false,
- responseType: 'text',
- resolveBodyOnly: false,
- maxRedirects: 10,
- prefixUrl: '',
- methodRewriting: true,
- ignoreInvalidCookies: false,
- context: {},
- // TODO: Set this to `true` when Got 12 gets released
- http2: false,
- allowGetBody: false,
- https: undefined,
- pagination: {
- transform: (response) => {
- if (response.request.options.responseType === 'json') {
- return response.body;
- }
- return JSON.parse(response.body);
- },
- paginate: response => {
- if (!Reflect.has(response.headers, 'link')) {
- return false;
- }
- const items = response.headers.link.split(',');
- let next;
- for (const item of items) {
- const parsed = item.split(';');
- if (parsed[1].includes('next')) {
- next = parsed[0].trimStart().trim();
- next = next.slice(1, -1);
- break;
- }
- }
- if (next) {
- const options = {
- url: new url_1.URL(next)
- };
- return options;
- }
- return false;
- },
- filter: () => true,
- shouldContinue: () => true,
- countLimit: Infinity,
- backoff: 0,
- requestLimit: 10000,
- stackAllItems: true
- },
- parseJson: (text) => JSON.parse(text),
- stringifyJson: (object) => JSON.stringify(object),
- cacheOptions: {}
- },
- handlers: [create_1.defaultHandler],
- mutableDefaults: false
- };
- const got = create_1.default(defaults);
- exports.default = got;
- // For CommonJS default export support
- module.exports = got;
- module.exports.default = got;
- module.exports.__esModule = true; // Workaround for TS issue: https://github.com/sindresorhus/got/pull/1267
- __exportStar(require("./create"), exports);
- __exportStar(require("./as-promise"), exports);
|