* 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>
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;
* 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 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>
* 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>
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>
* 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>
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>
* 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>
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>
* 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>
* 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
* Fixing password encoding with special characters in basic authentication
* Adding test to check if password with non-Latin1 characters pass
Co-authored-by: petr.mares <petr.mares@linecorp.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
There is a bug in react native Android platform when using get method. It will trigger a 'Network Error' when passing the requestData which is an empty string to request.send function. So if the requestData is an empty string we can set it to null as well to fix the bug.
Co-authored-by: Jay <jasonsaayman@gmail.com>
* 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>
When calling an HTTP resource redirecting to a HTTPS one with a keepAlive agent. We get the following error:
```
TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"
at new ClientRequest (_http_client.js:119:11)
at Object.request (https.js:281:10)
at RedirectableRequest._performRequest (/Users/jthomassey/projects/ecom-shop-web/node_modules/follow-redirects/index.js:169:24)
at RedirectableRequest._processResponse (/Users/jthomassey/projects/ecom-shop-web/node_modules/follow-redirects/index.js:260:10)
at ClientRequest.RedirectableRequest._onNativeResponse (/Users/jthomassey/projects/ecom-shop-web/node_modules/follow-redirects/index.js:50:10)
at Object.onceWrapper (events.js:277:13)
at ClientRequest.emit (events.js:189:13)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
at Socket.socketOnData (_http_client.js:442:20)
```
This can be tested here :
```
const http = require('http');
const https = require('https');
const axios = require('axios');
axios.get('http://www.photobox.fr', { httpAgent: http.Agent({ keepAlive:true }), httpsAgent: https.Agent({ keepAlive:true }) })
.then(response => {
console.log(response);
console.log(response.headers);
})
.catch(error => {
console.log(error);
});
```
Axios delegate the redirection to the follow-redirect package which accept an option `agents` for both http and https agent see : https://github.com/follow-redirects/follow-redirects#per-request-options
* 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.
* Adding support for no_proxy env variable
* Adds support for the no_proxy environment variable commonly available
with programs supporting the http_proxy/https_proxy environment
variables.
* Adds tests to test the no_proxy environment variable.
* Adding documentation for the proxy env variables
* Adds documentation to README.md for the supported, conventional
http_proxy, https_proxy, and no_proxy environment variables.