Commit Graph

237 Commits

Author SHA1 Message Date
Jason Saayman
24c45391b6
fix: backport the fixes from the v1 branch 2026-04-10 21:17:29 +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
Gabe Mendoza
02c3c69ced
fix: backport allowAbsoluteUrls vuln fix to v0.x (#6829)
* allowAbsoluteUrls

* fix logic - copied from v1.x

* update string

* undo changes to dist/axios.js

* chore: use strict equal in lib/core/buildFullPath.js

---------

Co-authored-by: Jay <jasonsaayman@gmail.com>
2025-03-19 12:24:25 +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
Justin Dhillon
92a0454cff
fix(backport): Uncaught ReferenceError req is not defined at AbortSignal.onCanceled (#6307) 2024-03-21 20:31:07 +02:00
lnjbr
2755df562b
fix(security): fixed CVE-2023-45857 by backporting withXSRFToken option to v0.x (#6091) 2024-01-19 18:33:41 +02:00
visortelle
871ef05112
Fix - Request ignores false, 0 and empty string as body values (#4786) 2022-06-14 21:53:09 +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
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
Tom Ceuppens
9be61dc1c9
Allow webpack users to overwrite buildins (#4715)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-16 08:46:46 +02:00
Maxime Bargiel
24f22b2b0b
Fixing proxy beforeRedirect regression (#4708) 2022-05-16 08:05:56 +02:00
Jamie Telin
c6ec5fc867
Fixing Z_BUF_ERROR when no content (#4701)
* Fix Z_BUF_ERROR when no content

* Refactored code

* Fix undefined check

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-12 07:27:39 +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
Jay
de5e006142
Revert "The content type option is left to the developer (#4550)" (#4699)
This reverts commit 9579bad1d3.
2022-05-09 20:16:21 +02:00
Dmitriy Mozgovoy
356b166182
Added blob to the list of protocols supported by the browser; (#4678)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-09 19:27:18 +02:00
Lawliet
9579bad1d3
The content type option is left to the developer (#4550)
* The content type option is left to the developer

If the browser recognizes the fault, it can protect the developer

Although I don't think Axios itself should interfere with developers' choices

This parameter is for compatibility with historical issues

* Update xhr.js

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-09 19:20:33 +02:00
JALAL
eef2f97281
replace deprecated substr() with slice() (#4468)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 21:39:40 +02:00
Jingyi Lin
ba85e0e385
style: fix word spelling ang lint style in comment (#4500)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 21:12:16 +02:00
Arthur Fiorette
ff1e5cd6c2
Include request and config when creating a CanceledError. (#4659)
* changes

* also include request

* revert comment

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 20:33:38 +02:00
zhoulixiang
e52af17ee8
opt: opt judgment code of cancel (#4587)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 19:04:58 +02:00
Dmitriy Mozgovoy
12faca87e0
Removed wrong argument for NetworkError constructor; (#4656) 2022-05-03 18:30:17 +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
9b8e0047e9 Merge branch 'fix#1603' of https://github.com/Tivix/axios into Tivix-fix#1603 2022-04-01 19:57:44 +02:00
Jay
8699891b8e Fixed merge conflicts 2022-04-01 18:40:12 +02:00
Jay
ac659112db Fixed issues created when merging 0.26.1 2022-03-19 14:36:42 +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
80387424e4 Removed all old error classes 2022-03-10 08:30:59 +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
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
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
Daniel
ea0d9c69f7
Adding error handling inside stream end callback (#3967)
* Adding error handling inside end callback  for response streams

* Updating error handling in stream end callback

* Update http.js

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-23 19:28:10 +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
Doowonee
55e6577b75
Adding a socket handler for keep TCP connection (#3422)
This is not http keepalive option it is TCP level
which is lower than HTTP.

It will send meanless ack flag packet to server.
so it woudn't be drop TCP connection by server side
like Firewall, Loadbalancer, Nginx etc.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 20:56:14 +02:00
Andrey Pechkurov
ebedf6b653
Avoid unnecessary Buffer allocations (#3321) 2021-12-22 20:50:05 +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
Dobes Vandermeer
96956e30ba
Improve timeout error when timeout is browser default (#3209)
I seems like the browser imposes a default timeout despite the documented default timeout being "never".  When this timeout occurs, axios confusingly reports an error "timeout of 0ms exceeded".  This change the message to avoid the confusing "0ms" part.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-16 21:16:43 +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
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