Commit Graph

92 Commits

Author SHA1 Message Date
Jason Saayman
24c45391b6
fix: backport the fixes from the v1 branch 2026-04-10 21:17:29 +02:00
Jay
16ae9508dd
refactor: update ci for v0.x (#7407)
* refactor: rennovate ci

* chore: improve publish

* chore: lock dts

* chore: do ci install

* fix: tests

* chore: remove husky

* chore: clarify versioning scheme

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: feedback

* chore: small fix to publish yml

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-17 21:10:51 +02:00
Felix Bernhard
d7ff1409c6
fix: backport DOS via __proto__ key in merge config fix to v0.x (#7388)
* backport fix

* add unit tests

* use `require()` instead of `import`
2026-02-11 08:19:32 +02:00
Felix Bernhard
a1b1d3f073
fix: backport maxContentLength vulnerability fix to v0.x (#7034)
* backport `maxContentLength` check for `data:` protocol urls

* backport test for `estimateDataURLDecodedBytes`

* use CommonJS export

* use `var` instead of `const`

* replace `let` with `var`

* use standard function instead of arrow function
2025-09-16 16:21:06 +02:00
nishimori daisuke
0630c329f7
fix: modify log while request is aborted (#4917)
* fix: modify log while request is aborted

since the previous log 'maxContentLength size of {maxContentLength} exceeded' does not represent an acutual error, I just modified the sentence.

* fix: change error kind

* fix: fix test about stream aborted pattern

---------

Co-authored-by: Jay <jasonsaayman@gmail.com>
2024-12-05 21:20:49 +02:00
Sol Zhu
2e36cdb67f
fix(backport): fix paramsSerializer function validation (#6361)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2024-05-24 18:44:36 +02:00
Sean Powell
146848f3e4
fix: backported commit #6167 and #6163 (#6402) 2024-05-24 18:38:36 +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
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 2de3cabc60.

* Revert "Fixing proxy beforeRedirect regression"

This reverts commit 57befc3215.
2022-05-11 19:24:14 +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
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
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
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
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
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
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
duibu05
4461761fcb
Fixed The timeoutErrorMessage property in config not work with Node.js (fixes #3580) (#3581)
* The timeoutErrorMessage property in config not work with Node.js (#3580)

* Adding "should respect the timeoutErrorMessage property" test case

Co-authored-by: Will Loo <duibu05@126.com>

* The timeoutErrorMessage property in config not work with Node.js (#3580)

* Fixing The timeoutErrorMessage property in config not work with Node.js (#3580)

* Updating http adapter

* Adding reject config.timeoutErrorMessage when setup

Co-authored-by: Will Loo <duibu05@126.com>

* Fixing The timeoutErrorMessage property in config not work with Node.js (#3580)

* Fixing The timeoutErrorMessage property in config not work with Node.js (#3580)

* Update http adapter

* Make changes as suggested after code review

Co-authored-by: Will Loo <duibu05@126.com>

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-01-18 18:40:18 +02:00
Paulo Renato
c00c4ddd87
Fixing maxBodyLength enforcement (#3786)
* Adding request body length validation on HTTP adapter

* Removing error code assertion on HTTP's body length support test

 * Removed due to the error being thrown by axios itself now, instead of follow-redirects

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-23 10:19:02 +02:00
Kohta Ito
c5fe05bdff
Adding aborted event handler (#3916)
* Adding test of aborts request

* Adding aborted event handler

* Fixing timing of setting rejected flag

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-10-29 10:05:01 +02:00
DigitalBrainJS
7f1236652a Refactored AxiosError to a constructor;
Refactored `Cancel` to a constructor, a subclass of the `AxiosError`;
Expose CanceledError class;
Refactored axios error codes;
Added `toFlatObject` util;
2021-10-14 19:15:16 +03: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
Matt R. Wilson
f3ca6371ca
Caseless header comparing in HTTP adapter. (#2880)
* Caseless header comparing in HTTP adapter.

It was adding User-Agent and removing Authorization, but only when
existing headers had the exact right casing. Node uses caseless logic
when managing headers.

This was causing some requests to have `User-Agent` appended to the
headers object and overriding provided agent strings.

Also included is an update to not override the `Content-Length` if it
was already defined in the options. It can be desirable to manually
specify a content length that does not match the data on hand.
Especially for testing.

* Fix eslint error

* fixup: update state UA logic

Play nice with https://github.com/axios/axios/pull/3703

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-07 20:30:30 +02:00
Daniel Lopretto
dbc634cf70
Remove charset in tests (#3807)
* removed charset setting when setting default header

* Remove charset from tests

Co-authored-by: mpark86 <dev.minuk.park@gmail.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
Co-authored-by: Pilot <timemachine@ctrl-c.club>
2021-05-21 07:51:31 +02:00
Philipe Gouveia Paixão
199c8aab64
Adding parseInt to config.timeout (#3781)
* Adding parseInt to config.timeout

* Fixing test message
2021-05-06 15:54:22 +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
Mike Bishop
b0959f0301
Adding ability to omit User-Agent header (#3703)
* Adding ability to omit User-Agent header

* Update line to be more compact

* Add unit tests for user-agent cases

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-03-29 16:47:29 +02:00
Daniel Lopretto
f2057f77b2
Testing and cleanup of transformResponse (#3377)
- Tests for transformResponse
 - Remove eslint error by renaming the var
 - Test that there data a length to avoid JSON.parse headache
 - Use `util.isString()` over `typeof`

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-03-24 08:22:03 +02:00
Daniel Lopretto
8b0f373df0
Use different socket for Win32 test (#3375)
* Remove the skipping of the `socket` http test

* Use different socket path for Win32

 - See: https://github.com/nodejs/node-v0.x-archive/blob/master/test/simple/test-pipe-stream.js#L73
 - Also: https://github.com/nodejs/node-v0.x-archive/blob/master/test/common.js#L39

* Updating axios in types to be lower case (#2797)

Co-authored-by: Xianming Zhong <chinesedfan@qq.com>

Co-authored-by: Pilot <timemachine@ctrl-c.club>
Co-authored-by: Remco Haszing <remcohaszing@gmail.com>
Co-authored-by: Xianming Zhong <chinesedfan@qq.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-12-09 13:04:58 +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
Daniel Lopretto
c7329fefc8
Hotfix: Prevent SSRF (#3410)
* Reproducing the Vulnerability

* Prevent SSRF

* Cleanup

* Refactor to skip duplicate code

* Tests for correct passed data.

* Code review changes.
2020-11-24 08:44:00 +02:00
Daniel Lopretto
768825589f
Remove the skipping of the socket http test (#3364)
Co-authored-by: Pilot <timemachine@ctrl-c.club>
2020-10-30 08:54:42 +02:00
Cr
16aa2ce7fa
Fixing response with utf-8 BOM can not parse to json (#2419)
* fix: remove byte order marker (UTF-8 BOM) when transform response

* fix: remove BOM only utf-8

* test: utf-8 BOM

* fix: incorrect param name

Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-07-01 19:14:52 +02: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
Xianming Zhong
5214445139
Add test for redirecting with too large response (#2695) 2020-02-29 19:54:41 +08:00
jennynju
9267d4def1
Fixing unit test failure in Windows OS (#2601)
Co-authored-by: Xianming Zhong <chinesedfan@qq.com>
2020-02-15 19:03:34 +08:00
multicolaure
6fe506fda2 Do not modify config.url when using a relative baseURL (resolves #1628) (#2391)
* Adding tests to show config.url mutation

Because config.url is modified while processing the request
when the baseURL is set,
it is impossible to perform a retry with the provided config object.

Ref #1628

* Fixing url combining without modifying config.url

As config.url is not modified anymore during the request processing.
The request can safely be retried after it failed with the provided
config.

resolves #1628
2019-09-05 12:43:55 -03:00
Rikki Gibson
21ae22dbd3 Preserve HTTP method when following redirect (#1758)
Resolves #1158

This modifies http.js to uppercase the HTTP method, similar to xhr.js, before passing the request off to the transport. This causes follow-redirects to preserve the HTTP method when automatically making a request to the next URL.
2018-08-27 17:26:38 +02:00