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>
- 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>
- 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>
* 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 failing test
* Fixing #2587 default custom config persisting
* Adding Concat keys and filter duplicates
* Fixed value from CPE
* update for review feedbacks
* no deepMerge
* only merge between plain objects
* fix rename
* always merge config by mergeConfig
* extract function mergeDeepProperties
* refactor mergeConfig with all keys, and add special logic for validateStatus
* add test for resetting headers
* add lots of tests and fix a bug
* should not inherit `data`
* use simple toString
* revert #1845
Co-authored-by: David Tanner <david.tanner@lifeomic.com>
Co-authored-by: Justin Beckwith <justin.beckwith@gmail.com>
* Fixing default transformRequest of TypedArrays with buffer pools
A buffer pool is a large ArrayBuffer of a preset size used with a TypedArray
such as Uint8Array. This can speed up performance when constructing TypedArrays
of unknown sizes, and is a technique used by Node with their Buffers, and
by libraries like dcodeIO/protobuf.js.
Because the ArrayBuffer of such a TypedArray is much longer than the array
itself, using `.buffer` to transform the array before POSTing results in
sending a request with many extraneous empty bytes, which is wastefule and may
result in unexpected behavior.
Using `.slice()` before grabbing the ArrayBuffer fixes the problem by creating
a new TypedArray with a buffer of the expected length.
Signed-off-by: Zac Delventhal <delventhalz@gmail.com>
* Adding test for using default transformRequest with buffer pools
Adds a new test to the default transformRequest, running it on a
Uint8Array with a byte length of 16, but a much larger ArrayBuffer
with a byte length of 256. The transformed array should not include
any extra bytes, and so must have a byte length of just 16.
Signed-off-by: Zac Delventhal <delventhalz@gmail.com>
Co-authored-by: Zac Delventhal <zac@bitwise.io>
Co-authored-by: Jay <jasonsaayman@gmail.com>
* removing @ character from replacement list since it is a reserved character
* Updating buildURL test to not include the @ character
* Removing console logs
Co-authored-by: Jay <jasonsaayman@gmail.com>
* 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>
* Failing test for #1252
* Only delete header keys that match an HTTP verb if the value is a non-string
Co-authored-by: David Ko <david.ko@pvtmethod.com>
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>
* Name function to avoid ESLint func-names warning
* Switch params config to merge list and update tests
* Restore testing of both false and null
* Restore test cases for keys without defaults
* Include test for non-object values that aren't false-y.
* Revert "Update Webpack + deps, remove now unnecessary polyfills (#2410)"
This reverts commit 189b34c45a.
* Fix build (#2496)
* Change syntax to see if build passes
* Test commit
* Test with node 10
* Test adding all browsers in travis
* remove other browsers when running on travis
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