2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-14 18:42:33 +03:00

Axios ES2017 (#4787)

* Added AxiosHeaders class;

* Fixed README.md href;

* Fixed a potential bug with headers normalization;

* Fixed a potential bug with headers normalization;
Refactored accessor building routine;
Refactored default transforms;
Removed `normalizeHeaderName` helper;

* Added `Content-Length` accessor;
Added missed `has` accessor to TS types;

* Added `AxiosTransformStream` class;
Added progress capturing ability for node.js environment;
Added `maxRate` option to limit the data rate in node.js environment;
Refactored event handled by `onUploadProgress` && `onDownloadProgress` listeners in browser environment;
Added progress & data rate tests for the http adapter;
Added response stream aborting test;
Added a manual progress capture test for the browser;
Updated TS types;
Added TS tests;
Refactored request abort logic for the http adapter;
Added ability to abort the response stream;

* Remove `stream/promises` & `timers/promises` modules usage in tests;

* Use `abortcontroller-polyfill`;

* Fixed AxiosTransformStream dead-lock in legacy node versions;
Fixed CancelError emitting in streams;

* Reworked AxiosTransformStream internal logic to optimize memory consumption;
Added throwing an error if the request stream was silently destroying (without error) Refers to #3966;

* Treat the destruction of the request stream as a cancellation of the request;
Fixed tests;

* Emit `progress` event in the next tick;

* Initial refactoring;

* Refactored Mocha tests to use ESM;

* Refactored Karma tests to use rollup preprocessor & ESM;
Replaced grunt with gulp;
Improved dev scripts;
Added Babel for rollup build;

* Added default commonjs package export for Node build;
Added automatic contributors list generator for package.json;

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Dmitriy Mozgovoy
2022-06-18 12:19:27 +03:00
committed by GitHub
parent 1db715dd3b
commit bdf493cf8b
125 changed files with 10462 additions and 7291 deletions
+11 -11
View File
@@ -1,4 +1,4 @@
var AxiosError = require("../../lib/core/AxiosError");
import AxiosError from "../../lib/core/AxiosError";
describe('transform', function () {
beforeEach(function () {
@@ -10,7 +10,7 @@ describe('transform', function () {
});
it('should transform JSON to string', function (done) {
var data = {
const data = {
foo: 'bar'
};
@@ -23,7 +23,7 @@ describe('transform', function () {
});
it('should transform string to JSON', function (done) {
var response;
let response;
axios('/foo').then(function (data) {
response = data;
@@ -45,7 +45,7 @@ describe('transform', function () {
it('should throw a SyntaxError if JSON parsing failed and responseType is "json" if silentJSONParsing is false',
function (done) {
var thrown;
let thrown;
axios({
url: '/foo',
@@ -74,7 +74,7 @@ describe('transform', function () {
);
it('should send data as JSON if request content-type is application/json', function (done) {
var response;
let response;
axios.post('/foo', 123, {headers: {'Content-Type': 'application/json'}}).then(function (_response) {
response = _response;
@@ -98,7 +98,7 @@ describe('transform', function () {
});
it('should not assume JSON if responseType is not `json`', function (done) {
var response;
let response;
axios.get('/foo', {
responseType: 'text',
@@ -111,7 +111,7 @@ describe('transform', function () {
done(err);
});
var rawData = '{"x":1}';
const rawData = '{"x":1}';
getAjaxRequest().then(function (request) {
request.respondWith({
@@ -128,7 +128,7 @@ describe('transform', function () {
});
it('should override default transform', function (done) {
var data = {
const data = {
foo: 'bar'
};
@@ -145,7 +145,7 @@ describe('transform', function () {
});
it('should allow an Array of transformers', function (done) {
var data = {
const data = {
foo: 'bar'
};
@@ -164,7 +164,7 @@ describe('transform', function () {
});
it('should allowing mutating headers', function (done) {
var token = Math.floor(Math.random() * Math.pow(2, 64)).toString(36);
const token = Math.floor(Math.random() * Math.pow(2, 64)).toString(36);
axios('/foo', {
transformRequest: function (data, headers) {
@@ -179,7 +179,7 @@ describe('transform', function () {
});
it('should normalize \'content-type\' header when using a custom transformRequest', function (done) {
var data = {
const data = {
foo: 'bar'
};