2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00
Commit Graph

20 Commits

Author SHA1 Message Date
Willian Agostini 569f028a58 fix: added a option to choose between legacy and the new request/response interceptor ordering
* test: add request interceptor tests for legacy and ordered execution

* feat: add legacy interceptor request/response ordering option

---------

Co-authored-by: Jay <jasonsaayman@gmail.com>
2026-01-30 08:12:04 +02:00
Jay ee90dfc28a fix: issues with version 1.13.3 (#7352) 2026-01-27 08:04:06 +02:00
Tackoil 5945e40bb1 fix(interceptor): handle the error in the same interceptor (#6269)
* fix(interceptor): handle the error in the same interceptor

* fix(interceptor): pass the config and data in promise chain

* fix(interceptor): filter out unexpected config and data in promise chain

---------

Co-authored-by: Jay <jasonsaayman@gmail.com>
2026-01-08 21:11:34 +02:00
Dmitriy Mozgovoy bdf493cf8b 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>
2022-06-18 11:19:27 +02:00
Landro3 544cf134f3 Interceptor clear (#4248)
* Adding interceptor clearing

* Fixing spacing

* changed clear to empty array

* fixed interceptor clear test

Co-authored-by: Andrew <Andrew@Andrews-MacBook-Pro.local>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-05 21:31:06 +02:00
Wolfram Kriesing e6aef5a1c4 (Add tests to) document how multiple inceptors work (#3564)
* Add a group for the multiple-interceptors tests.

The current test contains a lot of details that are worth being tested
separately and also made explicit. This is what is coming with the next changes.

* Fix indentation.

* Make explicit that the test only tests the interception of the fulfilled part.

* Indent.

* Make the test just test a tiny bit, as described.

The more explicit the test, the better we can 1) describe what it does
and use that for the docs to make them understandable 2) have a better
explicit description of the API (in case we want to modify it) and 3) have
a regression test when changing.

* Add a test that explicitly shows that the order of interceptors is as they were added.

* Pull out reusable code, to make the tests more explicitly stating the things they care about.

* Write a test showing that the responses are not merged or anything,
only the last one in the chain is returned.

* Make visible that the interceptors are a chain, one receives its predecessor's data.

* Test what happens when the interceptor throws.

* Refactor, add another group of tests and pull helper function there.

The previous change to also catch in the helper function was not needed
for any of the tests above, so remove it and put it in the describe-block
below where it is needed.
Just trying to write the specific code needed, not more.
Not sure about the impact for failing tests, I am glad about input.
But the main intention here is to have minimal code, explicit tests and
not too much generic code which might break itself eventually.

* Documenting that the following reject-interceptor gets called.

* Documenting how the interceptor chain handles caught rejections.

* Document "multiple interceptors".

I just extracted the test descriptions from the new/modified tests.
And I also learned that I should improve the test descriptions, the
tests are just in a GIVEN-WHEN-THEN structure, so I can also use those
terms better. Will do this next.

* Transfer the better readable descriptions as I changed them in the README back into the tests.

After I had updated the README using the test descriptions I realized how
the test descriptions can be improved, so I did this "moving" the learnings
back into the code.

* Be a bit more explicit, it was not clear when reading, imho.

* Add new lines to be kinda consistent with the rest of the file.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 21:14:52 +02:00
Julian Hollmann 83ae3830e4 Correctly add response interceptors to interceptor chain (#4013) 2021-09-04 20:55:38 +02:00
Sasha Korotkov 62d6256039 issue#2609 | Sasha | predictable axios requests (#2702)
* issue#2609 | Sasha | predictable axios requests

- axios requests are not delayed by pre-emptive promise creation by default
- add options to interceptors api ("synchronous" and "runWhen")
- add documentation and unit tests

* issue#2609 | Sasha | pull request feedback changes

* issue#2609 | Sasha | additional feedback changes

* issue#2609 | Sasha | put back try/catch

* issue#2609 | Sasha | add 2 adapter unit tests

- remove check for requestCancelled

Co-authored-by: ak71845 <alexandre.korotkov@kroger.com>
Co-authored-by: Xianming Zhong <chinesedfan@qq.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-03-01 11:11:35 +02:00
Haven 2b8562694e Fixing baseURL not working in interceptors (#950)
* Fixing baseURL not working in interceptors

* add test for  modify base URL in request interceptor
2017-08-12 14:15:27 +02:00
Nick Uraltsev 46a9639ef2 Fixing sporadically failing tests 2016-10-29 21:58:06 -07:00
Matt Zabriskie e833a2f7e4 Invoke request transformers after request interceptors
closes #352
2016-06-23 14:55:22 -06:00
Matt Zabriskie dcbb352262 Moving test helpers and auto-loading them 2016-03-07 13:21:27 -07:00
Matt Zabriskie 955d5a02e4 Run ALL the tests 😸 2016-03-05 23:29:29 -07:00
Matt Zabriskie dc07ef2559 Fixing tests for IE 2016-03-05 23:17:39 -07:00
Matt Zabriskie 371b82a2a0 Cleaning up tests a bit 2016-03-04 10:35:05 -07:00
mzabriskie b745600ab7 Using webpack for testing 2015-03-18 10:45:06 -06:00
mzabriskie 0438dd3bac Updating karma 2015-02-17 01:11:39 -07:00
mzabriskie 9e3830cf92 Adding support for removing interceptors 2015-01-23 01:32:54 -07:00
torkvalo ecd9f7391c Fixes failing tests for the IE8/IE9 capitalized verb bug. 2014-12-10 13:37:11 +01:00
Jason Dobry 5bb39f3279 Initial interceptor implementation. 2014-12-06 00:14:28 -07:00