2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-21 13:24:11 +03:00
Commit Graph

1072 Commits

Author SHA1 Message Date
Jay 63dfce85ab Releasing v0.25 2022-01-18 09:13:27 +02:00
Jay dccaeb1b68 Updated changelog for release 2022-01-18 09:06:19 +02:00
Gustavo Sales 51f3ccb08e Updating follow-redirects with security updates (#4379)
Co-authored-by: Gustavo Sales <gustavo@blastradius.ai>
2022-01-13 07:56:28 +02:00
Brian Adams ccc9516af8 Fixing removing package-lock from gitignore (#4346)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-29 07:30:54 +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
Felipe Carvalho 4fbf61dc75 Adding responseEncoding prop type in AxiosRequestConfig (#3918)
* Adding responseEncoding prop type in AxiosRequestConfig

* Update index.d.ts

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-23 19:07:46 +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
Andrew Ovens 962f9ab712 Update upgrade guide for https proxy setting (#3604)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 21:21:03 +02:00
Wolfram Kriesing e6aef5a1c4 (Add tests to) document how multiple inceptors work (#3564)
* Add a group for the multiple-interceptors tests.

The current test contains a lot of details that are worth being tested
separately and also made explicit. This is what is coming with the next changes.

* Fix indentation.

* Make explicit that the test only tests the interception of the fulfilled part.

* Indent.

* Make the test just test a tiny bit, as described.

The more explicit the test, the better we can 1) describe what it does
and use that for the docs to make them understandable 2) have a better
explicit description of the API (in case we want to modify it) and 3) have
a regression test when changing.

* Add a test that explicitly shows that the order of interceptors is as they were added.

* Pull out reusable code, to make the tests more explicitly stating the things they care about.

* Write a test showing that the responses are not merged or anything,
only the last one in the chain is returned.

* Make visible that the interceptors are a chain, one receives its predecessor's data.

* Test what happens when the interceptor throws.

* Refactor, add another group of tests and pull helper function there.

The previous change to also catch in the helper function was not needed
for any of the tests above, so remove it and put it in the describe-block
below where it is needed.
Just trying to write the specific code needed, not more.
Not sure about the impact for failing tests, I am glad about input.
But the main intention here is to have minimal code, explicit tests and
not too much generic code which might break itself eventually.

* Documenting that the following reject-interceptor gets called.

* Documenting how the interceptor chain handles caught rejections.

* Document "multiple interceptors".

I just extracted the test descriptions from the new/modified tests.
And I also learned that I should improve the test descriptions, the
tests are just in a GIVEN-WHEN-THEN structure, so I can also use those
terms better. Will do this next.

* Transfer the better readable descriptions as I changed them in the README back into the tests.

After I had updated the README using the test descriptions I realized how
the test descriptions can be improved, so I did this "moving" the learnings
back into the code.

* Be a bit more explicit, it was not clear when reading, imho.

* Add new lines to be kinda consistent with the rest of the file.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 21:14:52 +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
Black-Hole 476ee88442 chore: ignore yarn.lock file (#3545)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 21:06:36 +02:00
Remco Haszing 4c8b02de94 Adding axios-test-instance to ecosystem (#3496)
`axios-test-instance` is a package that allows users to write tests for NodeJS
servers using Axios.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 21:00:46 +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
Stefano Magni 5431634fab Fixing Cancel' signature. (#3152) (#3153)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 20:30:50 +02:00
Brandon Faulkner 6b4fd93e68 Expand Headers types (#4144)
* Expand Headers types

* Add undefined to allowed types

* Add semicolon
2021-11-16 17:06:21 +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 1885ac79c5 Adding dev branch to CI 2021-10-27 08:02:39 +02:00
Rijk van Zanten c218b7fd98 Update CHANGELOG.md (#4219)
* Update CHANGELOG.md

The mentioned pull request in the latest changelog was unrelated to the listed change. I believe this is the correct PR.

* Update CHANGELOG.md

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-10-26 08:59:22 +02:00
Jay 53d6d37556 Adding minfied files 2021-10-25 19:47:37 +02:00
Jay 6d613b4fe4 Updated changelog 2021-10-25 19:46:09 +02:00
Rodry 2c9cc76ee9 revert: change type of AxiosResponse to any (#4186)
* revert: change type of AxiosResponse to any

* types: add back default types

My bad xD

* Remove redundant default params
2021-10-22 10:14:23 +02:00
Jay 1025d1231a Release v0.23.0 2021-10-12 17:34:26 +02:00
Jay 6d1e30fd80 Prepared release notes 2021-10-12 10:34:20 +02:00
HyperLifelll9 20e8b6bc8c chore(docs): rename Angular to AngularJS (#4114)
* chore(docs): rename Angular to AngularJS

As we all know, Angular and AngularJS are separate, and now we often say Angular refers to Angular2+.

* Update README.md

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-10-12 10:06:11 +02:00
Remco Haszing 94a9344799 Test types (#4140)
* Distinguish request and response data types

* Fix Axios headers type

`axios.headers` is not of the same type as `request.headers`, so a new type
`AxiosDefaults` was introduced

* Replace grunt-ts with dtslint

This asserts that the type definitions are valid in the specified TypeScript
version and above. This is the same tool that is used by DefinitelyTyped.

* Remove grunt-ts

* Restore typescript dependency

* Fix missing semicolons

Co-authored-by: Claas Augner <github@caugner.de>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-10-12 09:53:10 +02:00
Dmitriy Mozgovoy fce210a67e Fixed TransitionalOptions typings (#4147)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-10-12 09:46:16 +02:00
Jay 547815d9fd Mending merge conflict 2021-10-12 09:43:02 +02:00
Evgeniy e462973a4b fix response headers types (#4136)
* fix response headers types

some keys like 'set-cookie' are arrays https://github.com/axios/axios/blob/master/lib/helpers/parseHeaders.js#L45

* split header types
2021-10-07 19:23:29 +02:00
Claas Augner 7c9a5c5c84 Fix missing semicolon in typings (#4115)
Fixes #4109.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-10-06 21:11:00 +02:00
Remco Haszing 6c002323a6 Change never type to unknown (#4142)
* Distinguish request and response data types

* Change never type to unknown

Using `never` was a workaround I introduced in 3002, because `unknown` wasn’t
supperted by all relevant versions of TypeScript at the time. It is now, and
it is much more correct.

Co-authored-by: Claas Augner <github@caugner.de>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-10-06 20:13:06 +02:00
Claas Augner 28a06e6d95 Distinguish request and response data types (#4116)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-10-06 20:10:01 +02:00
Jay ba9c193037 Release/v0.22.0 (#4143)
* 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-06 20:02:30 +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
Igor Randjelovic 7d6bddba2d Fix node version on CI (#4069)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-17 08:41:32 +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
Paweł Szymański e52cd3ac64 Add globalObject: 'this' to webpack config (#3176)
This should solve the issue of undefined `this` when importing from an ES6 module.
I've put steps to reproduce in [this comment](https://github.com/axios/axios/issues/1861#issuecomment-669832435).

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-16 21:08:40 +02:00
Evan Finkelstein 2bc250786f Adding insecureHTTPParser type to AxiosRequestConfig 2021-09-15 13:47:14 -07: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
Remco Haszing 90205f8ab7 Change headers type to string record (#3021)
This correctly reflects the type in a more type safe manner.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-05 14:14:12 +02:00
Remco Haszing 92b29d2775 Make the default type of response data never (#3002)
This requires TypeScript users to explicitly define the type of the data they
are consuming.

Before this, data was `any` by default. This means TypeScript consumers didn’t
get type safety if they forgot to specify the type.

Technically this is a breaking change for TypeScript users, as this will report
errors if they forgot to specifiy the response type. The simplest workaround
would be to explicitly set the response type to `any`, so it’s not breaking
much.

The `unknown` type is probably a slightly better fit, but this requires
TypeScript ^3.

`data` is still `any` in the very specific use case mentioned in
https://github.com/microsoft/TypeScript/issues/38969

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-05 14:11:25 +02:00
Carlos Chida 4eeb3b17e2 Improved type-safety for AxiosRequestConfig (#2995)
* Improved type-safety for AxiosRequestConfig

- AxiosRequestConfig is now a generic type whose template corresponds to data

Signed-off-by: Carlos Chida <carlos.chida@starchitecture.eu>

* Fixed tests

- TS tests now match the behaviour described in the PR

Signed-off-by: Carlos Chida <carlos.chida@starchitecture.eu>

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-05 14:06:05 +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