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.
This allows users of axios inside `electron` to provide the [`net`](https://electron.atom.io/docs/api/net/) module as the http transport instead of using nodes http/https modules. This gives a whole bunch of things to Electron users including automatic proxy resolution.
* Adding a way to disable all proxy processing
When the proxy field in configuration is === false all proxy processing is
disabled. This specifically disable the 'http_proxy' environment variable
handling.
Fixes#635
Related to #434
* Change readme wording
From review comment on PR (#691)