Commit Graph

400 Commits

Author SHA1 Message Date
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
c9aca75257 Releasing v0.26.0 2022-02-13 16:20:24 +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
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
Jay
63dfce85ab Releasing v0.25 2022-01-18 09:13:27 +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
C. Lewis
a76571abec
Use native Array.isArray() in utils.js (#3836)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-23 18:45:44 +02:00
狼族小狈
a8cd75a081
Update isAbsoluteURL.js (#3809)
Escaping non-special characters in strings, template literals, and regular expressions doesn't have any effect, as demonstrated in the following example:

https://eslint.org/docs/rules/no-useless-escape

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-23 13:33:16 +02:00
Hirotaka Tagawa / wafuwafu13
95792908f0
Adding error handling when missing url (#3791)
* Fixing error message when missing url

* Fixing missing url

* Adding missing url case

* Update Axios.js

* Update requests.spec.js

* Update api.spec.js

* Update api.spec.js

* Update api.spec.js

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-23 10:53:40 +02:00
Ben Carp
99648153ce
toFormData helper function (#3757)
* adding toFormData test

* adding toFormData

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-23 10:21:51 +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
Black-Hole
6fca6a7027
refactor(helpers): optimize the logic of isAxiosError (#3546)
1. add the judgment of null

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 21:09:33 +02:00
Emil Broman
cd1b82bb76
Removing code relying on strict mode behaviour for arguments (#3470)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 20:58:12 +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
enofan
716d5def2f
Update utils.js (#3342)
update isFormdata,isArrayBuffer and isURLSearchParams, because value and Formdata(ArrayBuffer or URLSearchParams) are not the same Window sometimes.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 20:37:27 +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
Jay
53d6d37556 Adding minfied files 2021-10-25 19:47:37 +02:00
Jay
1025d1231a Release v0.23.0 2021-10-12 17:34:26 +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
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
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
Greg Byrne
cd7ff042b0
Adding HTTP status code to error.toJSON (#2956)
* Adding HTTP status code to error.toJSON (axios#2947)

* Adding Error display div to internal server client.html

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-05 13:45:24 +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
Isaac Whitfield
69d3cc4f3e
Allow create() to be used recursively (#2795)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-05 12:24:50 +02:00
Julian Hollmann
83ae3830e4
Correctly add response interceptors to interceptor chain (#4013) 2021-09-04 20:55:38 +02:00
ready-research
5b457116e3
Security fix for ReDoS (#3980) 2021-08-30 14:33:43 +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
Mark
0ece97c7a9
Fixing quadratic runtime when setting a maxContentLength (#3738)
Previously checking whether a response has exceeded `maxContentLength` was
quadratic with respect to the number of chunks in the response stream and
also caused unnecessary additional memory usage.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-05-04 19:48:20 +02:00
TagawaHirotaka
a18a0eccb5
Updating lib/core/README.md about Dispatching requests (#3772)
* Updating lib/core/README.md :Dispatching requests

* Fixing expression
2021-04-30 09:08:50 +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
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
Daniel Lopretto
59ab559386
Update dev dependencies (#3401)
- Everything still works as expected.
  - Remove bundlesize
    - It still uses libtorb which is deprecated and broken on Win and
      requires a full suite of build tools on Mac. Keeping it in the
      package makes it difficult for anyone filing issues to run tests.
    - See: #3396
  - Update grunt and it's plugins
  - Update karma to v4...so much faster!
    - Changed the karma config. Better changes: #3394
  - Update Webpack
    - Uses terser over uglify
  - Update eslint
    - Caused an error in util.js from the `global` directive so the
      directive is removed (it was not needed).
  - Update typescript
    - The old version of tsc didn't know about new features in
      @types/node (like `asserts value`).

Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-12-16 10:25:06 +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
Jason Kwok
f472e5da5f
Adding a type guard for AxiosError (#2949)
Co-authored-by: Jason Kwok <JasonHK@users.noreply.github.com>
2020-11-03 10:01:07 +02:00
George Cheng
9a78465a92
Revert "Fixing overwrite Blob/File type as Content-Type in browser. (#1773)" (#3289)
This reverts commit f3cc053fb9.
2020-10-13 10:19:37 +02:00
Xianming Zhong
fa3673710e
fix axios.delete ignores config.data (#3282)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-10-01 09:46:32 +02:00
Allan Cruz
04d45f2091
Fixing requestHeaders.Authorization (#3287) 2020-09-20 10:19:48 +08: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