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

327 Commits

Author SHA1 Message Date
Dmitriy Mozgovoy ea87ebfe6d fix(headers): fixed the filtering logic of the clear method; (#5542) 2023-02-11 16:31:03 +02:00
Dmitriy Mozgovoy 96d336f527 fix(formdata): add hotfix to use the asynchronous API to compute the content-length header value; (#5521) 2023-02-02 00:55:05 +02:00
Dmitriy Mozgovoy 9263473154 chore(ci): fixed contributors avatar rendering for CHANGELOG.md; (#5514) 2023-01-31 17:56:09 +02:00
Dmitriy Mozgovoy 6ac574e00a feat(fomdata): added support for spec-compliant FormData & Blob types; (#5316) 2023-01-31 01:10:39 +02:00
ItsNotGoodName 65e8d1e28c fix(http): add zlib headers if missing (#5497) 2023-01-31 00:49:37 +02:00
Dmitriy Mozgovoy 9915635c69 fix(headers): fixed & optimized clear method; (#5507) 2023-01-31 00:35:06 +02:00
Dmitriy Mozgovoy 580f1e8033 fix(types): fixed AxiosHeaders to handle spread syntax by making all methods non-enumerable; (#5499) 2023-01-26 16:01:06 +02:00
Dmitriy Mozgovoy 2a71f49bc6 fix(types): renamed RawAxiosRequestConfig back to AxiosRequestConfig; (#5486) 2023-01-23 01:09:18 +02:00
Dmitriy Mozgovoy 6486929f70 Fix AxiosRequestHeaders & AxiosHeaders types; (#5482) 2023-01-21 17:31:24 +02:00
Dmitriy Mozgovoy 08119634a2 fix(types): fixed AxiosRequestConfig header interface by refactoring it to RawAxiosRequestConfig; (#5420) 2023-01-06 02:02:08 +02:00
Dmitriy Mozgovoy 7a2f901f42 Fix/typescript tests (#5375)
* chore(ci): Add release-it script;

* chore(ci): add `release:no-npm` script to release the package without making an npm release;

* fix(test): fixed `d.ts` typings;
refactor(test): refactor typescript tests;
2022-12-14 22:49:49 +02:00
Dmitriy Mozgovoy 1e58a659ec fix: fixed Brotli decompression; (#5353)
test: added decompression tests;
fix: added legacy `x-gzip` & `x-compress` encoding types;
2022-12-07 20:57:02 +02:00
Winnie 56e9ca1a86 fix: Add missing HttpStatusCode (#5345) 2022-12-06 22:34:48 +02:00
Kevin Ennis 26874603b3 feat: export mergeConfig (#5151)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-12-01 20:41:57 +02:00
Dmitriy Mozgovoy 9041c7d272 Fixed decompression for responses without Content-Length header (#5306)
* Fixed decompression for responses without `content-length` header;

* Add Brotli encoding to the `Accept-Encoding` header only if it is supported.

* `content-length` header transformation moved up;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-12-01 16:22:20 +02:00
Ivan Barsukov 786b113a40 fix: removing multiple/trailing/leading whitespaces (#5022)
* fix: removing multiple/trailing/leading whitespaces

* Reverting changes in the dist directory

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-11-25 15:56:31 +02:00
Dmitriy Mozgovoy d032edda08 Refactored adapters loader; (#5277)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-11-22 20:53:56 +02:00
Dmitriy Mozgovoy a3d901777b Fixed Z_BUF_ERROR when content-encoding is set but the response body is empty; (#5250)
Fixed download progress capturing for compressed responses;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-11-22 20:49:26 +02:00
Dmitriy Mozgovoy b7ee49f637 Added toJSONObject util; (#5247)
Fixed AxiosError.toJSON method to avoid circular references;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-11-22 20:44:24 +02:00
Jay bb59a737bb chore: release v1.2.0 2022-11-10 20:55:34 +02:00
Remco Haszing abf954185a fix: fix TypeScript type definitions for commonjs (#5196)
This is done by duplicating `index.d.ts` into `index.d.cts`, and
modifying it for CommonJS. The same was done for type tests.

Unfortunately I was unable to find a way to re-use types without
drastically changing the code base.

To test this, a minimum TypeScript version of 4.7 is needed, so it has
been updated. The old types still work with older TypeScript versions.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-11-10 20:23:02 +02:00
Dmitriy Mozgovoy ab77a40e1c Fixed & Imporoved AxiosHeaders class (#5224)
* Refactored AxiosHeaders class;

* Added support for instances of AxiosHeaders as a value for the headers option;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-11-07 21:11:42 +02:00
Dmitriy Mozgovoy c0a723ab6c Added support for Axios to be loaded with require('axios').default; (#5225)
Added module import tests;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-11-07 20:32:24 +02:00
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