axios 1.1.3 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of axios might be problematic. Click here for more details.
- package/CHANGELOG.md +298 -75
- package/{UPGRADE_GUIDE.md → MIGRATION_GUIDE.md} +1 -1
- package/README.md +61 -25
- package/dist/axios.js +886 -582
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +3189 -0
- package/dist/browser/axios.cjs.map +1 -0
- package/dist/esm/axios.js +886 -625
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +1 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +972 -554
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +528 -0
- package/index.d.ts +116 -56
- package/index.js +12 -3
- package/lib/adapters/adapters.js +59 -0
- package/lib/adapters/http.js +87 -34
- package/lib/adapters/xhr.js +7 -4
- package/lib/axios.js +13 -3
- package/lib/core/Axios.js +10 -8
- package/lib/core/AxiosError.js +1 -1
- package/lib/core/AxiosHeaders.js +102 -80
- package/lib/core/dispatchRequest.js +7 -2
- package/lib/core/mergeConfig.js +50 -46
- package/lib/defaults/index.js +2 -21
- package/lib/env/classes/FormData.js +2 -2
- package/lib/env/data.js +1 -1
- package/lib/helpers/HttpStatusCode.js +71 -0
- package/lib/helpers/ZlibHeaderTransformStream.js +28 -0
- package/lib/helpers/formDataToStream.js +111 -0
- package/lib/helpers/readBlob.js +15 -0
- package/lib/helpers/speedometer.js +1 -1
- package/lib/helpers/toFormData.js +5 -15
- package/lib/platform/browser/classes/FormData.js +1 -1
- package/lib/platform/browser/index.js +20 -0
- package/lib/utils.js +107 -9
- package/package.json +86 -14
- package/bin/ssl_hotfix.js +0 -22
- package/gulpfile.js +0 -88
- package/karma.conf.cjs +0 -250
- package/lib/adapters/index.js +0 -33
- package/rollup.config.js +0 -90
- package/tsconfig.json +0 -14
- package/tslint.json +0 -6
package/gulpfile.js
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
import gulp from 'gulp';
|
2
|
-
import fs from 'fs-extra';
|
3
|
-
import axios from './index.js';
|
4
|
-
|
5
|
-
gulp.task('default', async function(){
|
6
|
-
console.log('hello!');
|
7
|
-
});
|
8
|
-
|
9
|
-
const clear = gulp.task('clear', async function() {
|
10
|
-
await fs.emptyDir('./dist/')
|
11
|
-
});
|
12
|
-
|
13
|
-
const bower = gulp.task('bower', async function () {
|
14
|
-
const npm = JSON.parse(await fs.readFile('package.json'));
|
15
|
-
const bower = JSON.parse(await fs.readFile('bower.json'));
|
16
|
-
|
17
|
-
const fields = [
|
18
|
-
'name',
|
19
|
-
'description',
|
20
|
-
'version',
|
21
|
-
'homepage',
|
22
|
-
'license',
|
23
|
-
'keywords'
|
24
|
-
];
|
25
|
-
|
26
|
-
for (let i = 0, l = fields.length; i < l; i++) {
|
27
|
-
const field = fields[i];
|
28
|
-
bower[field] = npm[field];
|
29
|
-
}
|
30
|
-
|
31
|
-
await fs.writeFile('bower.json', JSON.stringify(bower, null, 2));
|
32
|
-
});
|
33
|
-
|
34
|
-
async function getContributors(user, repo, maxCount = 1) {
|
35
|
-
const contributors = (await axios.get(
|
36
|
-
`https://api.github.com/repos/${encodeURIComponent(user)}/${encodeURIComponent(repo)}/contributors`,
|
37
|
-
{ params: { per_page: maxCount } }
|
38
|
-
)).data;
|
39
|
-
|
40
|
-
return Promise.all(contributors.map(async (contributor)=> {
|
41
|
-
return {...contributor, ...(await axios.get(
|
42
|
-
`https://api.github.com/users/${encodeURIComponent(contributor.login)}`
|
43
|
-
)).data};
|
44
|
-
}))
|
45
|
-
}
|
46
|
-
|
47
|
-
const packageJSON = gulp.task('package', async function () {
|
48
|
-
const CONTRIBUTION_THRESHOLD = 3;
|
49
|
-
|
50
|
-
const npm = JSON.parse(await fs.readFile('package.json'));
|
51
|
-
|
52
|
-
try {
|
53
|
-
const contributors = await getContributors('axios', 'axios', 15);
|
54
|
-
|
55
|
-
npm.contributors = contributors
|
56
|
-
.filter(
|
57
|
-
({type, contributions}) => type.toLowerCase() === 'user' && contributions >= CONTRIBUTION_THRESHOLD
|
58
|
-
)
|
59
|
-
.map(({login, name, url}) => `${name || login} (https://github.com/${login})`);
|
60
|
-
|
61
|
-
await fs.writeFile('package.json', JSON.stringify(npm, null, 2));
|
62
|
-
} catch (err) {
|
63
|
-
if (axios.isAxiosError(err) && err.response && err.response.status === 403) {
|
64
|
-
throw Error(`GitHub API Error: ${err.response.data && err.response.data.message}`);
|
65
|
-
}
|
66
|
-
throw err;
|
67
|
-
}
|
68
|
-
});
|
69
|
-
|
70
|
-
const env = gulp.task('env', async function () {
|
71
|
-
var npm = JSON.parse(await fs.readFile('package.json'));
|
72
|
-
|
73
|
-
await fs.writeFile('./lib/env/data.js', Object.entries({
|
74
|
-
VERSION: npm.version
|
75
|
-
}).map(([key, value]) => {
|
76
|
-
return `export const ${key} = ${JSON.stringify(value)};`
|
77
|
-
}).join('\n'));
|
78
|
-
});
|
79
|
-
|
80
|
-
const version = gulp.series('bower', 'env', 'package');
|
81
|
-
|
82
|
-
export {
|
83
|
-
bower,
|
84
|
-
env,
|
85
|
-
clear,
|
86
|
-
version,
|
87
|
-
packageJSON
|
88
|
-
}
|
package/karma.conf.cjs
DELETED
@@ -1,250 +0,0 @@
|
|
1
|
-
/* eslint-disable no-console */
|
2
|
-
/* eslint-disable no-unused-vars */
|
3
|
-
/* eslint-disable func-names */
|
4
|
-
// Karma configuration
|
5
|
-
// Generated on Fri Aug 15 2014 23:11:13 GMT-0500 (CDT)
|
6
|
-
|
7
|
-
'use strict';
|
8
|
-
|
9
|
-
var resolve = require('@rollup/plugin-node-resolve').default;
|
10
|
-
var commonjs = require('@rollup/plugin-commonjs');
|
11
|
-
|
12
|
-
function createCustomLauncher(browser, version, platform) {
|
13
|
-
return {
|
14
|
-
base: 'SauceLabs',
|
15
|
-
browserName: browser,
|
16
|
-
version: version,
|
17
|
-
platform: platform
|
18
|
-
};
|
19
|
-
}
|
20
|
-
|
21
|
-
module.exports = function(config) {
|
22
|
-
var customLaunchers = {};
|
23
|
-
var browsers = process.env.Browsers && process.env.Browsers.split(',');
|
24
|
-
var sauceLabs;
|
25
|
-
|
26
|
-
if (process.env.SAUCE_USERNAME || process.env.SAUCE_ACCESS_KEY) {
|
27
|
-
customLaunchers = {};
|
28
|
-
|
29
|
-
var runAll = true;
|
30
|
-
var options = [
|
31
|
-
'SAUCE_CHROME',
|
32
|
-
'SAUCE_FIREFOX',
|
33
|
-
'SAUCE_SAFARI',
|
34
|
-
'SAUCE_OPERA',
|
35
|
-
'SAUCE_IE',
|
36
|
-
'SAUCE_EDGE',
|
37
|
-
'SAUCE_IOS',
|
38
|
-
'SAUCE_ANDROID'
|
39
|
-
];
|
40
|
-
|
41
|
-
options.forEach(function(opt) {
|
42
|
-
if (process.env[opt]) {
|
43
|
-
runAll = false;
|
44
|
-
}
|
45
|
-
});
|
46
|
-
|
47
|
-
// Chrome
|
48
|
-
if (runAll || process.env.SAUCE_CHROME) {
|
49
|
-
customLaunchers.SL_Chrome = createCustomLauncher('chrome');
|
50
|
-
// customLaunchers.SL_ChromeDev = createCustomLauncher('chrome', 'dev');
|
51
|
-
// customLaunchers.SL_ChromeBeta = createCustomLauncher('chrome', 'beta');
|
52
|
-
}
|
53
|
-
|
54
|
-
// Firefox
|
55
|
-
if (runAll || process.env.SAUCE_FIREFOX) {
|
56
|
-
//customLaunchers.SL_Firefox = createCustomLauncher('firefox');
|
57
|
-
// customLaunchers.SL_FirefoxDev = createCustomLauncher('firefox', 'dev');
|
58
|
-
// customLaunchers.SL_FirefoxBeta = createCustomLauncher('firefox', 'beta');
|
59
|
-
}
|
60
|
-
|
61
|
-
// Safari
|
62
|
-
if (runAll || process.env.SAUCE_SAFARI) {
|
63
|
-
// customLaunchers.SL_Safari7 = createCustomLauncher('safari', 7);
|
64
|
-
// customLaunchers.SL_Safari8 = createCustomLauncher('safari', 8);
|
65
|
-
customLaunchers.SL_Safari9 = createCustomLauncher(
|
66
|
-
'safari',
|
67
|
-
9.0,
|
68
|
-
'OS X 10.11'
|
69
|
-
);
|
70
|
-
customLaunchers.SL_Safari10 = createCustomLauncher(
|
71
|
-
'safari',
|
72
|
-
'10.1',
|
73
|
-
'macOS 10.12'
|
74
|
-
);
|
75
|
-
customLaunchers.SL_Safari11 = createCustomLauncher(
|
76
|
-
'safari',
|
77
|
-
'11.1',
|
78
|
-
'macOS 10.13'
|
79
|
-
);
|
80
|
-
}
|
81
|
-
|
82
|
-
// Opera
|
83
|
-
if (runAll || process.env.SAUCE_OPERA) {
|
84
|
-
// TODO The available versions of Opera are too old and lack basic APIs
|
85
|
-
// customLaunchers.SL_Opera11 = createCustomLauncher('opera', 11, 'Windows XP');
|
86
|
-
// customLaunchers.SL_Opera12 = createCustomLauncher('opera', 12, 'Windows 7');
|
87
|
-
}
|
88
|
-
|
89
|
-
// IE
|
90
|
-
if (runAll || process.env.SAUCE_IE) {
|
91
|
-
customLaunchers.SL_IE11 = createCustomLauncher('internet explorer', 11, 'Windows 8.1');
|
92
|
-
}
|
93
|
-
|
94
|
-
// Edge
|
95
|
-
if (runAll || process.env.SAUCE_EDGE) {
|
96
|
-
customLaunchers.SL_Edge = createCustomLauncher('microsoftedge', null, 'Windows 10');
|
97
|
-
}
|
98
|
-
|
99
|
-
// IOS
|
100
|
-
if (runAll || process.env.SAUCE_IOS) {
|
101
|
-
// TODO IOS7 capture always timesout
|
102
|
-
// customLaunchers.SL_IOS7 = createCustomLauncher('iphone', '7.1', 'OS X 10.10');
|
103
|
-
// TODO Mobile browsers are causing failures, possibly from too many concurrent VMs
|
104
|
-
// customLaunchers.SL_IOS8 = createCustomLauncher('iphone', '8.4', 'OS X 10.10');
|
105
|
-
// customLaunchers.SL_IOS9 = createCustomLauncher('iphone', '9.2', 'OS X 10.10');
|
106
|
-
}
|
107
|
-
|
108
|
-
// Android
|
109
|
-
if (runAll || process.env.SAUCE_ANDROID) {
|
110
|
-
// TODO Mobile browsers are causing failures, possibly from too many concurrent VMs
|
111
|
-
// customLaunchers.SL_Android4 = createCustomLauncher('android', '4.4', 'Linux');
|
112
|
-
// customLaunchers.SL_Android5 = createCustomLauncher('android', '5.1', 'Linux');
|
113
|
-
}
|
114
|
-
|
115
|
-
browsers = Object.keys(customLaunchers);
|
116
|
-
|
117
|
-
sauceLabs = {
|
118
|
-
recordScreenshots: false,
|
119
|
-
connectOptions: {
|
120
|
-
// port: 5757,
|
121
|
-
logfile: 'sauce_connect.log'
|
122
|
-
},
|
123
|
-
public: 'public'
|
124
|
-
};
|
125
|
-
} else if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') {
|
126
|
-
console.log(
|
127
|
-
'Cannot run on Sauce Labs as encrypted environment variables are not available to PRs. ' +
|
128
|
-
'Running on Travis.'
|
129
|
-
);
|
130
|
-
browsers = ['Firefox'];
|
131
|
-
} else if (process.env.GITHUB_ACTIONS === 'true') {
|
132
|
-
console.log('Running ci on Github Actions.');
|
133
|
-
browsers = ['FirefoxHeadless', 'ChromeHeadless'];
|
134
|
-
} else {
|
135
|
-
browsers = browsers || ['Chrome'];
|
136
|
-
console.log(`Running ${browsers} locally since SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are not set.`);
|
137
|
-
}
|
138
|
-
|
139
|
-
config.set({
|
140
|
-
// base path that will be used to resolve all patterns (eg. files, exclude)
|
141
|
-
basePath: '',
|
142
|
-
|
143
|
-
|
144
|
-
// frameworks to use
|
145
|
-
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
146
|
-
frameworks: ['jasmine-ajax', 'jasmine', 'sinon'],
|
147
|
-
|
148
|
-
|
149
|
-
// list of files / patterns to load in the browser
|
150
|
-
files: [
|
151
|
-
{pattern: 'test/specs/__helpers.js', watched: false},
|
152
|
-
{pattern: 'test/specs/**/*.spec.js', watched: false}
|
153
|
-
],
|
154
|
-
|
155
|
-
|
156
|
-
// list of files to exclude
|
157
|
-
exclude: [],
|
158
|
-
|
159
|
-
|
160
|
-
// preprocess matching files before serving them to the browser
|
161
|
-
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
162
|
-
preprocessors: {
|
163
|
-
'test/specs/__helpers.js': ['rollup'],
|
164
|
-
'test/specs/**/*.spec.js': ['rollup']
|
165
|
-
},
|
166
|
-
|
167
|
-
rollupPreprocessor: {
|
168
|
-
plugins: [
|
169
|
-
resolve({browser: true}),
|
170
|
-
commonjs()
|
171
|
-
],
|
172
|
-
output: {
|
173
|
-
format: 'iife',
|
174
|
-
name: '_axios',
|
175
|
-
sourcemap: 'inline'
|
176
|
-
}
|
177
|
-
},
|
178
|
-
|
179
|
-
|
180
|
-
// test results reporter to use
|
181
|
-
// possible values: 'dots', 'progress'
|
182
|
-
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
183
|
-
// Disable code coverage, as it's breaking CI:
|
184
|
-
// reporters: ['dots', 'coverage', 'saucelabs'],
|
185
|
-
reporters: ['progress'],
|
186
|
-
|
187
|
-
|
188
|
-
// web server port
|
189
|
-
port: 9876,
|
190
|
-
|
191
|
-
|
192
|
-
// Increase timeouts to prevent the issue with disconnected tests (https://goo.gl/nstA69)
|
193
|
-
captureTimeout: 4 * 60 * 1000,
|
194
|
-
browserDisconnectTimeout: 10000,
|
195
|
-
browserDisconnectTolerance: 1,
|
196
|
-
browserNoActivityTimeout: 4 * 60 * 1000,
|
197
|
-
|
198
|
-
|
199
|
-
// enable / disable colors in the output (reporters and logs)
|
200
|
-
colors: true,
|
201
|
-
|
202
|
-
|
203
|
-
// level of logging
|
204
|
-
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
205
|
-
logLevel: config.LOG_INFO,
|
206
|
-
|
207
|
-
|
208
|
-
// enable / disable watching file and executing tests whenever any file changes
|
209
|
-
autoWatch: false,
|
210
|
-
|
211
|
-
|
212
|
-
// start these browsers
|
213
|
-
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
214
|
-
browsers: browsers,
|
215
|
-
|
216
|
-
|
217
|
-
// Continuous Integration mode
|
218
|
-
// if true, Karma captures browsers, runs the tests and exits
|
219
|
-
singleRun: false,
|
220
|
-
|
221
|
-
// Webpack config
|
222
|
-
webpack: {
|
223
|
-
mode: 'development',
|
224
|
-
cache: true,
|
225
|
-
devtool: 'inline-source-map',
|
226
|
-
externals: [
|
227
|
-
{
|
228
|
-
'./adapters/http': 'var undefined'
|
229
|
-
}
|
230
|
-
]
|
231
|
-
},
|
232
|
-
|
233
|
-
webpackServer: {
|
234
|
-
stats: {
|
235
|
-
colors: true
|
236
|
-
}
|
237
|
-
},
|
238
|
-
|
239
|
-
|
240
|
-
// Coverage reporting
|
241
|
-
coverageReporter: {
|
242
|
-
type: 'lcov',
|
243
|
-
dir: 'coverage/',
|
244
|
-
subdir: '.'
|
245
|
-
},
|
246
|
-
|
247
|
-
sauceLabs: sauceLabs,
|
248
|
-
customLaunchers: customLaunchers
|
249
|
-
});
|
250
|
-
};
|
package/lib/adapters/index.js
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
import utils from '../utils.js';
|
2
|
-
import httpAdapter from './http.js';
|
3
|
-
import xhrAdapter from './xhr.js';
|
4
|
-
|
5
|
-
const adapters = {
|
6
|
-
http: httpAdapter,
|
7
|
-
xhr: xhrAdapter
|
8
|
-
}
|
9
|
-
|
10
|
-
export default {
|
11
|
-
getAdapter: (nameOrAdapter) => {
|
12
|
-
if(utils.isString(nameOrAdapter)){
|
13
|
-
const adapter = adapters[nameOrAdapter];
|
14
|
-
|
15
|
-
if (!nameOrAdapter) {
|
16
|
-
throw Error(
|
17
|
-
utils.hasOwnProp(nameOrAdapter) ?
|
18
|
-
`Adapter '${nameOrAdapter}' is not available in the build` :
|
19
|
-
`Can not resolve adapter '${nameOrAdapter}'`
|
20
|
-
);
|
21
|
-
}
|
22
|
-
|
23
|
-
return adapter
|
24
|
-
}
|
25
|
-
|
26
|
-
if (!utils.isFunction(nameOrAdapter)) {
|
27
|
-
throw new TypeError('adapter is not a function');
|
28
|
-
}
|
29
|
-
|
30
|
-
return nameOrAdapter;
|
31
|
-
},
|
32
|
-
adapters
|
33
|
-
}
|
package/rollup.config.js
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
import resolve from '@rollup/plugin-node-resolve';
|
2
|
-
import commonjs from '@rollup/plugin-commonjs';
|
3
|
-
import {terser} from "rollup-plugin-terser";
|
4
|
-
import json from '@rollup/plugin-json';
|
5
|
-
import { babel } from '@rollup/plugin-babel';
|
6
|
-
import autoExternal from 'rollup-plugin-auto-external';
|
7
|
-
import bundleSize from 'rollup-plugin-bundle-size'
|
8
|
-
|
9
|
-
const lib = require("./package.json");
|
10
|
-
const outputFileName = 'axios';
|
11
|
-
const name = "axios";
|
12
|
-
const input = './lib/axios.js';
|
13
|
-
|
14
|
-
const buildConfig = ({es5, browser = true, minifiedVersion = true, ...config}) => {
|
15
|
-
|
16
|
-
const build = ({minified}) => ({
|
17
|
-
input,
|
18
|
-
...config,
|
19
|
-
output: {
|
20
|
-
...config.output,
|
21
|
-
file: `${config.output.file}.${minified ? "min.js" : "js"}`
|
22
|
-
},
|
23
|
-
plugins: [
|
24
|
-
json(),
|
25
|
-
resolve({browser}),
|
26
|
-
commonjs(),
|
27
|
-
minified && terser(),
|
28
|
-
minified && bundleSize(),
|
29
|
-
...(es5 ? [babel({
|
30
|
-
babelHelpers: 'bundled',
|
31
|
-
presets: ['@babel/preset-env']
|
32
|
-
})] : []),
|
33
|
-
...(config.plugins || []),
|
34
|
-
]
|
35
|
-
});
|
36
|
-
|
37
|
-
const configs = [
|
38
|
-
build({minified: false}),
|
39
|
-
];
|
40
|
-
|
41
|
-
if (minifiedVersion) {
|
42
|
-
configs.push(build({minified: true}))
|
43
|
-
}
|
44
|
-
|
45
|
-
return configs;
|
46
|
-
};
|
47
|
-
|
48
|
-
export default async () => {
|
49
|
-
const year = new Date().getFullYear();
|
50
|
-
const banner = `// Axios v${lib.version} Copyright (c) ${year} ${lib.author} and contributors`;
|
51
|
-
|
52
|
-
return [
|
53
|
-
...buildConfig({
|
54
|
-
es5: true,
|
55
|
-
output: {
|
56
|
-
file: `dist/${outputFileName}`,
|
57
|
-
name,
|
58
|
-
format: "umd",
|
59
|
-
exports: "default",
|
60
|
-
banner
|
61
|
-
}
|
62
|
-
}),
|
63
|
-
|
64
|
-
...buildConfig({
|
65
|
-
output: {
|
66
|
-
file: `dist/esm/${outputFileName}`,
|
67
|
-
format: "esm",
|
68
|
-
preferConst: true,
|
69
|
-
exports: "named",
|
70
|
-
banner
|
71
|
-
}
|
72
|
-
}),
|
73
|
-
// Node.js commonjs build
|
74
|
-
{
|
75
|
-
input,
|
76
|
-
output: {
|
77
|
-
file: `dist/node/${name}.cjs`,
|
78
|
-
format: "cjs",
|
79
|
-
preferConst: true,
|
80
|
-
exports: "default",
|
81
|
-
banner
|
82
|
-
},
|
83
|
-
plugins: [
|
84
|
-
autoExternal(),
|
85
|
-
resolve(),
|
86
|
-
commonjs()
|
87
|
-
]
|
88
|
-
}
|
89
|
-
]
|
90
|
-
};
|
package/tsconfig.json
DELETED