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

304 Commits

Author SHA1 Message Date
Dmitriy Mozgovoy 0c3a1e9fde Refactored module exports; (#5162)
* Refactored build pipeline;
Added module exports tests;
Added missing ESM export for parity with Axios factory;
Added `toFormData`, `formToJSON`, `isAxiosError`, `spread`, `isCancel`, `all` as named export to `index.d.ts`;

* Added ESM entry test;

* Updated README.md `installing` section;

* Added TypeScript importing test;
Added missed `CanceledError` & `AxiosHeaders` to `AxiosStatic` interface;

* Exclude `/test/module/` from tslint;
2022-10-30 18:46:17 +02:00
ChronosMasterOfAllTime b0ebf9fcac Fix: Don't add null values to query string. (#5108)
* feat: add  boolean flag to mimic pre 1.x behavior for paramsSerializer custom function

* chore: update ParamsSerializer Readme

* fix: dont slice hash off URL if not appending params

* Omit nulls from formData serialization

* fix: dont add nulls or undefined values to arrays either

* readme update

* fix test

* chore: documentation

* chore: do TS properly

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-10-15 15:01:59 +02:00
Dmitriy Mozgovoy 9d4b016dde feat: added custom params serializer support; (#5113)
* Added custom params serializer support;

* Added missed semicolon;
Fixed allowUnknown option;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-10-13 22:12:10 +02:00
Patrick Petrovic 717f476b0f fix: restore proxy config backwards compatibility with 0.x (#5097)
* fix: restore proxy config backwards compatibility with 0.x

* Formatting

Co-authored-by: Patrick Petrovic <patrick@Air-de-Patrick.lan>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-10-13 21:55:20 +02:00
Dmitriy Mozgovoy 110ae9ae61 fix: handling of array values for AxiosHeaders (#5085)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-10-13 21:11:01 +02:00
shingo.sasaki a6e40c3bb2 fix(type): add clear to AxiosInterceptorManager (#5010)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-10-06 08:16:27 +02:00
Dmitriy Mozgovoy 3e4d52171e Fixed query params composing; (#5018)
* Fixes #4999;

* Added regression test;
2022-10-05 21:29:50 +02:00
Willian Agostini 58ec93a95e Allow null indexes on formSerializer and paramsSerializer (#4960)
* test: Failed test

Param indexes from formSerializer and paramsSerializer receiving null

Closes #4959

* fix: Allow null to indexes in SerializerOptions

Closes #4959

Co-authored-by: Willian Agostini <willian.agostini@fleetcor.com.br>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-09-29 08:18:35 +02:00
Luca Pizzini 05338f4454 Removed unused imports (#4949)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-09-28 21:16:14 +02:00
Stephen Jennings 64906bd886 require interceptors to return values (#4874)
Fixes #4873

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-09-26 21:11:29 +02:00
felipedamin 738fa63661 Use WHATWG URL API instead of url.parse() (#4852)
* replace url.parse with new whatwg url api

* remove comments

* use const instead of var

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-09-14 21:40:08 +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
Jay d82ea47dd3 fix(Tests): updating regex to allow for pre-releases 2022-05-31 21:12:55 +02:00
João Gabriel Quaresma 1504792765 Fixing content-type header repeated (#4745)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-28 11:52:50 +02:00
Victor Augusto a11f9501b8 Fix/4737/timeout error message for http (#4738)
* Fixing timeoutErrorMessage in http calls

When timeoutErrorMessage was set this did not change anything in the error message, with this change the error message will be the configured message

* Testing timeoutErrorMessage in http calls

When timeoutErrorMessage was set this did not change anything in the error message, with this change the error message will be the configured message

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-28 11:46:33 +02:00
Dmitriy Mozgovoy c008e57fe4 Added axios.formToJSON method; (#4735)
* Draft

* Added `formDataToJSON` helper;
Added `axios.formToJSON` method;
Added client tests;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-25 08:21:40 +02:00
Dmitriy Mozgovoy 934f390cc3 URL params serializer; (#4734)
* Refactored BuildURL helper to use URLSearchParams serializer;

* Updated typings;
Added TS test;
2022-05-25 08:16:38 +02:00
Dmitriy Mozgovoy 467025bdb7 Fixed bug #4727 : toFormData Blob issue on node>v17; (#4728)
* Fixed bug #4727;
Added node 18.x to the CI;
Added hotfix for `ERR_OSSL_EVP_UNSUPPORTED` issue with karma running on node >=17.x;
Added `cross-env` to allow running build and test scripts on Windows platforms;

* Added conditional setting of `--openssl-legacy-provider` option for node versions >=17.x;

* Refactored ssl-hotfix & test script;

* Fixed and refactored default max body length test due to ECONNRESET failure;

* Added test for converting the data uri to a Blob;
Fixed bug with parsing mime type for Blob;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-20 16:31:26 +02:00
Dimitris Halatsis e9c9f3392b Fix/4263/maxbodylength defaults (#4731)
* test(http): add test case for default body length in follow-redirects

* fix(http): provide proper default body length to follow-redirects

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-20 08:27:37 +02:00
Dmitriy Mozgovoy c30252f685 Added data URL support for node.js; (#4725)
* Added data URL support for node.js;
Added missed data URL protocol for the browser environment;
Optimized JSON parsing in the default response transformer;
Refactored project structure;
Added `cause` prop for AxiosError instance that refers to the original error if it was wrapped with `AxiosError.from` method;
Added fromDataURI helper;
Added test for handling data:url as an `arraybuffer|text|stream`;

* Added throwing of 405 HTTP error if the method is not GET;
2022-05-20 08:04:36 +02:00
Dmitriy Mozgovoy bd391247b4 Added the ability for the url-encoded-form serializer to respect the formSerializer config; (#4721)
Added test for `formSerializer` config in context of `url-encoded-form` serializer;
2022-05-17 08:26:35 +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
Maxime Bargiel 24f22b2b0b Fixing proxy beforeRedirect regression (#4708) 2022-05-16 08:05:56 +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
Maxime Bargiel 495d5fb133 Resolving proxy from env on redirect (#4436)
* Fixing http adapter to recompute proxy on redirect

Redirections can target different hosts or change the protocol
from http to https or vice versa. When the proxy option is
inferred from the environment, it should be recomputed when
the protocol or host changes because the proxy host can differ
or even whether to proxy or not can differ.

* Fixing proxy protocol handling

1) setProxy now changes request options protocol when using a proxy with explicit protocol.
2) As a result, selection of the correct transport can be simplified.
3) Legacy agent selection needs to be moved done accordingly. (Is 'agent' option even still used?)

* Using proxy-from-env library to handle proxy env vars

The proxy-from-env library is a popular, lightweight library that is
very easy to use and covers a few more cases, not to mention it has
extensive test coverage.

* Fixing proxy auth handling

* Adding test proving env vars are re-resolved on redirect

* Revert unnecessary change

* Fixing proxy beforeRedirect regression

* Fixing lint errors

* Revert "Fixing lint errors"

This reverts commit 2de3cabc60db2444e63a699bae9ec45531218a84.

* Revert "Fixing proxy beforeRedirect regression"

This reverts commit 57befc3215980e47333fedc1e9028cc22297540b.
2022-05-11 19:24:14 +02:00
Lukas Hroch ac96144dd3 fix(types): allow to specify partial default headers for instance creation (#4185)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-09 20:03:05 +02:00
Koki Oyatsu 2f50c8249b Adding HTTP status code for transformResponse (#4580)
* Adding HTTP status code for transformResponse

* refs #1214

* Fix wrong argument for tranformResponse

* Fix test wrong argument for tranformData

* Add test case for transformData

* Add test case for transformData (reference headers case)

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-09 19:25:16 +02:00
Spencer 9f6ba5ee43 Fixing instance.defaults.headers type (#4557)
* Fixing instance.defaults.headers type

* remove console.log()

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-09 19:12:53 +02:00
Dmitriy Mozgovoy de48c5d626 Fixed race condition on immediate requests cancellation (#4261)
* Fixes #4260: fixed race condition on immediate requests cancellation

* Update http.js

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-09 18:12:29 +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
Dmitriy Mozgovoy 384b7e6994 Added generic AxiosAbortSignal TS interface to avoid importing AbortController polyfill (#4229)
* Added generic `AxiosAbortSignal` TS interface to avoid importing AbortController polyfill;

* Renamed `AxiosAbortSignal` to `GenericAbortSignal` to use the same naming style as `GenericFormData`;

* Added TS test for `GenericAbortSignal` interface;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-04 21:23:01 +02:00
Maxime Bargiel 9ca2779d7a Fixing http tests to avoid hanging when assertions fail (#4435)
* Fixing cases of Axios hanging on test failures

* Fix max redirect assertion

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-04 17:54:14 +02:00
Dmitriy Mozgovoy c07998a621 Added generic TS types for the exposed toFormData helper; (#4668) 2022-05-03 20:29:50 +02:00
Des Preston 7920d11144 Updating AxiosError to include stack trace (#4624)
Related to discussions here https://github.com/axios/axios/issues/2387

Attempt to capture the stack trace at the time the error is created in
order to maintain context about where the error originates from.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 18:46:10 +02:00
Dmitriy Mozgovoy b9e9fb4fa0 Enhanced protocol parsing implementation to fix #4633; (#4639)
Added unit tests;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-04-27 11:30:50 +02:00
Dmitriy Mozgovoy 76432c18be Fixed FormData posting in browser environment by reverting #3785; (#4640)
* Fixed posting FormData in browser environment by reverting #3785;

* Added ability to keep `Content-Type` header in non-standard browser environments;

* Added browser test of FormData posting using external HTTP service (https://httpbin.org/post);

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-04-27 11:26:52 +02:00
Dmitriy Mozgovoy 4f7e3e3a7a Removed import of url module in browser build due to significant size overhead; (#4594)
Removed pointless `Malformed URL` checking in  client build;
2022-04-26 09:08:49 +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
Jay e52e4dbb57 Fixed errors when running tests 2022-03-10 21:25:55 +02:00
Jay 340ad9ec8c Fixed merge conflict 2022-03-09 19:57:04 +02:00
Jay d8d43c1ffd Mended merge conflicts 2022-03-09 19:41:56 +02:00
sakarit bdb7d76d40 Adding baseURL to be used in getUri(), also removing question mark trimming since there seems to be no obvious reason for it. (#3737)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-07 20:09:23 +02:00
João Gabriel Quaresma 195c8e5ff5 Returned error treated when requesting uncommon URL (#3544)
* Fixing error returned when requesting illegal URL

* Adding unit tests http.js

* Fixing error message axios invalid request from browser

* Adding unit tests requests.spec.js

* Adding at utils.js a new method: getProtocol

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-07 19:53:57 +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
Dmitriy Mozgovoy 170588f3d7 Refactored project file structure to avoid circular imports; (#4220)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-07 09:09:43 +02:00
Jay d660e29c1a Revert "Fixed isFormData predicate; (#4413)" (#4472)
This reverts commit 73e3bdb883.
2022-02-13 15:47:38 +02:00
Dmitriy Mozgovoy 73e3bdb883 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 through `form-data` package;
2022-02-02 13:48:44 +02:00
Jay cc86c6c49f Fix/remove url required (#4426)
* Removed error when url is null as this breaks current use cases for alot of projects

* Removed associated tests that check for the for url to not be empty
2022-01-27 08:39:25 +02:00
Daniel 1163588aa2 Added errors to be displayed when the query parsing process itself fails. (#3961)
* Adding errors when the query parsing process fails

* Updated error

* Removed unused variables

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-01-18 18:50:33 +02:00