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

221 Commits

Author SHA1 Message Date
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
Dmitriy Mozgovoy a02fe284df Updated README.md; (#4742)
Updated index.d.ts;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-26 08:13:27 +02:00
Dmitriy Mozgovoy c05ad48952 Fixed toFormData regression bug (unreleased) with Array-like objects serialization; (#4714)
Added `toURLEncodedForm` helper;
Added automatic payload serialization to `application/x-www-form-urlencoded` to have parity with `multipart/form-data`;
Added test of handling `application/x-www-form-urlencoded` body by express.js;
Updated README.md;
Added missed param in JSDoc;
Fixed hrefs in README.md;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-16 08:30:17 +02:00
Dmitriy Mozgovoy 807918bda2 Added enhanced toFormData implementation with additional options support; (#4704)
Updated default notation for arrays and objects to bracket style;
Added `multer/express.js` tests;
Updated README.md;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-11 19:30:08 +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
Afzal Sayed 7e56f8653c Fix grammatical issues in README (#4232)
* Fix grammatical issues in README

* Fix typo in COLLABORATOR_GUIDE.md

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-05 21:02:32 +02:00
reslear 1430393402 Update README.md (#4207)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-04 21:12:12 +02:00
Jay e8e4749ebf Updated all browser logos to be correct 2022-05-04 19:27:42 +02:00
Kai b4d87ce6ca Updating HTTP links in README.md to use HTTPS (#4387)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-04 18:15:37 +02:00
Kumar Shanu 6b1ae0b84a Edited readme with 3 updated browser icons. (#4414)
In the main readme file of axios, the icons for chrome, firefox and safari was not visible, which was giving a bit outdated vibes. I have updated all the three icons with the latest ones from  "https://www.iconfinder.com/icons/23799/firefox_icon" in 48px dimension. I hope now it looks good.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 21:46:08 +02:00
Alexander Shchukin 484443f251 fix url to defaults.js (#4532)
fix url to defaults.js

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 20:35:59 +02:00
Ted Robertson e9efc69f68 Emphasize the URLSearchParam built-in interface (#4590)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 19:00:38 +02:00
aong a41f129acf Update README.md (#4599)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 18:50:13 +02:00
Dan Mooney 8fb0f2689d Update README.md (#4649)
Fix grammar

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 18:40:15 +02:00
Jay 8699891b8e Fixed merge conflicts 2022-04-01 18:40:12 +02:00
Dmitriy Mozgovoy 6b9b05b907 Improved FormData support; (#4448)
* Fixed isFormData predicate;
Added support for automatic object serialization to FormData if `Content-Type` is `multipart/form-data`;
Added support for FormData to be overloaded using `config.env.FormData` option;
Added support for FormData in node.js environment through `form-data` package;

* Added the `form-data` package as a dependency for the server build;
Added tests for FormData payload;

* Added FormData automatic serialization section;
Refactored cancellation section;

* Reworked toFormData helper;
Expose toFormData helper as a static method;
Refactored transform request;
Added kindOf, kindOfTest, endsWith, isTypedArray util;
Refactored utils.js to use kindOf for tests;

* Fixed isFormData predicate; (#4413)

Added support for automatic object serialization to FormData if `Content-Type` is `multipart/form-data`;
Added support for FormData to be overloaded using `config.env.FormData` option;
Added support for FormData in node.js environment using `form-data` package;

(cherry picked from commit 73e3bdb883)

* Added shortcut methods `postForm`, `putForm`, `patchForm` to submit a Form;
Added ability to submit FileList object as a FormData;
Updated README.md;

* Updated README.md;
2022-03-14 20:22:10 +02:00
Rijk van Zanten 8e67551177 Update line on methods, update TS definition to allow strings (#3802)
Fixes #3140

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-08 08:26:07 +02:00
Zoran Kokeza 412d3bd607 Adding support for beforeRedirect config option (#3852)
* Adding support for beforeRedirect config option

* Adding tests for beforeRedirect

* Update README.md

Co-authored-by: Prabodh Meshram <prabodh.meshram7@gmail.com>

* fix types

Co-authored-by: Prabodh Meshram <prabodh.meshram7@gmail.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-07 19:46:08 +02:00
Nicholas Juntilla 3d13b67c56 Fix FormData example (#4391)
You need to have form.getBuffer() in order for the FormData library to submit from node.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-07 09:45:12 +02:00
Tomás Raiti 45cb5ad716 Updated README example to be coherent with the CommonJS usage (#4418)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-07 09:35:48 +02:00
CookieMr c5bdbd436d Update follow-redirects dependency due to Vurnerbility
Previous version of follow-redirects dependency is reported
by Snyk to have a vurnerbility.
https://app.snyk.io/test/npm/follow-redirects/1.14.7
2022-02-11 14:58:12 +01: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
HyperLifelll9 20e8b6bc8c chore(docs): rename Angular to AngularJS (#4114)
* chore(docs): rename Angular to AngularJS

As we all know, Angular and AngularJS are separate, and now we often say Angular refers to Angular2+.

* Update README.md

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-10-12 10:06:11 +02:00
Jay 76f09afc03 Release/v0.22.0 (#4107)
* fix/Avoid package.json import; (#4041)

* Added auto-generated config module `env/data.js` for importing package environment vars without importing the whole `package.json`;
Refactored `http.js` to use `env/data.js` instead of package.json;

* Added `env/data.js`;
Added `env/README.md`;

* Feat/export package version constant (#4065)

* Added auto-generated config module `env/data.js` for importing package environment vars without importing the whole `package.json`;
Refactored `http.js` to use `env/data.js` instead of package.json;

* Added `env/data.js`;
Added `env/README.md`;

* Export package version constant;

* Fixed cancelToken leakage; Added AbortController support; (#3305)

* Fixed cancelToken leakage;
Added AbortController support;

* Fixed typings;

* Documented `signal` option;

* Added processing of early cancellation using AbortController without sending a request;

Co-authored-by: Jay <jasonsaayman@gmail.com>

* Updating CI to run on release branches

* Fixed default transitional config for custom Axios instance; (#4052)

Refactored `/core/mergeConfig`;

Co-authored-by: Jay <jasonsaayman@gmail.com>

* Prepping v0.22.0 for release

* Updated date

Co-authored-by: Dmitriy Mozgovoy <robotshara@gmail.com>
2021-10-01 08:02:13 +02:00
Jay 4091b075f6 Release/0.21.4 (#4025)
* fix json transform when data is pre-stringified (#4020)

* [Updating] incorrect JSON syntax in README.md

* [Releasing] v0.21.4

Co-authored-by: Guillaume FORTAINE <guillaume+github@fortaine.com>
2021-09-06 17:35:06 +02:00
Fabiel Leon b5a1a67b3c Adding nodejs http.request option: insecureHTTPParser (#2930)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-05 13:43:49 +02:00
Sam Carlton e10a0270e9 Fix README typo under Request Config (#3825)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-08-13 14:55:00 +02:00
Mo Sattler e091491127 Update README.md (#3936)
Fixing the example JSON of `Request Config`

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-08-13 14:45:46 +02:00
Jay b42fbad57b Removed un-needed bracket
Removed un-needed bracket
2021-08-13 14:36:02 +02:00
Jay 520c8dccde Updating CI status badge (#3953)
Updated CI status badge to show Github workflow status
2021-08-13 14:35:20 +02:00
Jay 3958e9fbc8 Add explanation of cancel token (#3803)
Thanks to @socketpair for testing and checking this.
2021-05-18 09:08:20 +02:00
Johannes Jarbratt 94fc4ea716 Adding isAxiosError typeguard documentation (#3767)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-05-04 20:05:05 +02:00
Dmitriy Mozgovoy 5ad6994da3 JSON improvements: throw if JSON parsing failed; number, boolean can be passed directly as payload for encoding to JSON #2613, #61, #907 (#3688)
* Draft

* Added support for primitive types to be converted to JSON if the request Content-Type is 'application/json';
Added throwing SyntaxError if JSON parsing failed and responseType is json;
Added transitional option object;
Added options validator to assert transitional options;
Added transitional option `silentJSONParsing= true` for backward compatibility;
Updated README.md;
Updated typings;

* Fixed isOlderVersion helper;
Fixed typo;
Added validator.spec.js;

* Added forcedJSONParsing transitional option #2791

* `transformData` is now called in the default configuration context if the function context is not specified (for tests compatibility);

* Added `transitional.clarifyTimeoutError` to throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts;
Added support of onloadend handler if available instead of onreadystatechange;
Added xhr timeout test;
Fixed potential bug of xhr adapter with proper handling timeouts&errors (FakeXMLHTTPRequest failed to handle timeouts);
2021-04-19 18:55:34 +02:00
Jay c0317b7453 Update README.md (#3707) 2021-03-29 16:43:29 +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
Nisar Hassan Naqvi 535d0c45c1 move the mention of gitpod to the main readme + modify gitpod description. (#2637)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-02-17 08:28:00 +02:00
Ali Clark fe52a611ef Default headers example AUTH_TOKEN comment (#3539)
* Updating the 'Global axios defaults' README to use a safer example

The existing example usage it isn't safe in the general case as it can
lead to auth tokens being leaked to 3rd party endpoints by unexpectedly.

This change instead gives an example using
"axios.defaults.headers.common" to set the User-Agent, which is an
equally helpful use-case to document.

The 'Custom instance defaults' example just below the 'Global axios
defaults' example shows a method to set the 'Authorization' header
specific to a given API. I've also updated the variable in the 'Custom
instance defaults' code to use a semantically more relevant name within
that example.

* Revert the example instance name in response to PR request

* Reintroduce the Authorization example with a disclaimer about its usage

* Update wording nb -> important on usage comment

* Remove User-Agent example due to issues with this on Chrome and Safari

See https://github.com/axios/axios/issues/1231
Credit @chinesedfan for pointing this out
2021-01-12 16:52:42 +02:00
Jonathan Foster e426910be7 Protocol not parsed when setting proxy config from env vars (#3070)
* Fixing proxy protocol config when parsed from env vars

* Adding instructions to specify proxy protocol when setting proxy config

* Moved HTTPS proxy config instruction closer to example

* Clear https_proxy env var so as to not impact other tests
2020-12-03 09:36:50 +02:00
Kamil Posiadała c4300a88cf Adding support for URLSearchParams in node (#1900)
* Adding support for URLSearchParams in node

* Remove un-needed code

* Update utils.js

* Make changes as suggested

Co-authored-by: Kamil Posiadala <kamil.posiadala@codecentric.de>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-06-25 19:06:00 +02:00
Frostack bed6783452 add table of content (preview) (#3050)
* add toc (preview)

* remove toc in toc

Signed-off-by: Moni <usmoni@gmail.com>

* fix sublinks

* fix indentation

* remove redundant table links

* update caps and indent

* remove axios

Co-authored-by: Moni <usmoni@gmail.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-06-25 18:41:10 +02:00
jeffjing ee46dff3ef docs(): Detailed config options environment. (#2088)
* docs(): Detailed config options environment.

* Update README.md

Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-05-29 19:08:27 +02:00
Taegyeoung Oh d35b5b5902 Remove axios.all() and axios.spread() from Readme.md (#2727)
* Updating Readme.md
- remove axios.all(), axios.spread()

* Updating Readme.md
- replace example
- axios.all() -> Promise.all()
- axios.spread(function (acct, perms)) -> function (acct, perms)
- add deprecated mark

* Update README.md

Make changes after review

Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-05-27 19:43:08 +02:00
marcinx 6d36dbe7b7 Update README.md (#2887)
Small change to the data attribute doc of the config. A request body can also be set for DELETE methods but this wasn't mentioned in the documentation (it only mentioned POST, PUT and PATCH). Took my some 10-20 minutes until I realized that I don't need to manipulate the request body with transformRequest in the case of DELETE.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-05-27 19:26:13 +02:00
Samina Fu 021e741aa1 Add CDNJS version badge in README.md (#878)
This badge will show the version on CDNJS!

Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-05-22 16:09:09 +02:00
Jay fd57956a7e Documentation update to clear up ambiguity in code examples (#2928)
* Made a adjustment to the documenation to clear up any ambiguity around the use of "fs". This should help clear up that the code examples with "fs" cannot be used on the client side.

Co-authored-by: Jay <jason.saayman@basebone.com>
2020-05-05 13:44:07 +02:00
hexaez 16b5718954 Update README.md about validateStatus (#2912)
Rewrote the comment from "Reject only if the status code is greater than or equal to 500" to "Resolve only if the status code is less than 500"
2020-04-22 15:59:26 +02:00
Remco Haszing 5e0fb5fc99 Updating documentation for usage form-data (#2805)
Closes #2049

Co-authored-by: Xianming Zhong <chinesedfan@qq.com>
2020-04-05 18:01:38 +08:00
Spencer von der Ohe 42eb9dfabc Adding option to disable automatic decompression (#2661)
* Adding ability to disable auto decompression

* Updating decompress documentation in README

* Fixing test\unit\adapters\http.js lint errors

* Adding test for disabling auto decompression

* Removing changes that fixed lint errors in tests

* Removing formating change to unit test

Co-authored-by: Xianming Zhong <chinesedfan@qq.com>
2020-03-06 22:01:58 +08:00
Gustavo López 6642ca9aa1 Add independent maxBodyLength option (#2781)
* Add independent option to set the maximum size of the request body

* Remove maxBodyLength check

* Update README

* Assert for error code and message
2020-03-06 21:55:19 +08:00
Alexandru Ungureanu 67e560da10 Added Response header access instructions (#1901)
* Added Response header access instructions

* Added note about using bracket notation
2020-02-26 19:03:20 +08:00