* 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
* 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>
* 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>
* 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>
* 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>
* 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;
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>
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>
* 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.
* 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>
* 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;
* 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>
* 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>
* 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>
Refactored `Cancel` to a constructor, a subclass of the `AxiosError`;
Expose CanceledError class;
Refactored axios error codes;
Added `toFlatObject` util;
* 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>
* 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>
* 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);
* 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>
- 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>
* 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
* 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>
* 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
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.