2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-18 12:39:44 +03:00
Commit Graph

38 Commits

Author SHA1 Message Date
Daniel Lopretto dbc634cf70 Remove charset in tests (#3807)
* removed charset setting when setting default header

* Remove charset from tests

Co-authored-by: mpark86 <dev.minuk.park@gmail.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
Co-authored-by: Pilot <timemachine@ctrl-c.club>
2021-05-21 07:51:31 +02:00
Dmitriy Mozgovoy 5ad6994da3 JSON improvements: throw if JSON parsing failed; number, boolean can be passed directly as payload for encoding to JSON #2613, #61, #907 (#3688)
* 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);
2021-04-19 18:55:34 +02:00
Daniel Lopretto f2057f77b2 Testing and cleanup of transformResponse (#3377)
- 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>
2021-03-24 08:22:03 +02:00
Jay f2b478f7ff Revert "Fixing default transformRequest with buffer pools (#1511)" (#2982)
This reverts commit a9a3b5e22b.
2020-05-27 20:05:26 +02:00
Zac Delventhal a9a3b5e22b Fixing default transformRequest with buffer pools (#1511)
* 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>
2020-05-27 14:42:41 +02:00
Gustavo López 6642ca9aa1 Add independent maxBodyLength option (#2781)
* Add independent option to set the maximum size of the request body

* Remove maxBodyLength check

* Update README

* Assert for error code and message
2020-03-06 21:55:19 +08:00
Joshua Melvin 1b07fb9365 Fixing issue 2195 - order of if/else blocks is causing unit tests mocking XHR. (#2201) 2019-09-13 09:35:59 -03:00
Jacob Wejendorp b4c5d35d28 Fixing accept header normalization (#1698)
Fixes override behavior for `accept` header, when case does not match
the one used in defaults.js
2018-08-06 23:25:23 -06:00
Tim Garthwaite 0b3db5d87a Fixing defaults to use httpAdapter if available (#1285)
* Fixing defaults to use httpAdapter if available
* Use a safer, cross-platform method to detect the Node environment
2018-04-11 09:23:38 -06:00
Martti Laine 143bbbe1b9 Spec for mergeConfig, finalize logic 2018-04-07 15:54:56 +02:00
Emily Morehouse b6920570c5 Merge branch 'master' into bugfix/allow-method-in-instance-config 2018-02-19 23:33:44 -07:00
MiguelMadero f7310ca083 Documents the timeout default 2018-02-14 17:49:39 -08:00
ahmed ayoub 6566598603 allowing default method for an instance 2017-10-10 21:17:37 +02:00
Jeremy Fowler 188334439f support node buffers less than 8192 bytes (#773) 2017-04-08 13:55:34 +02:00
John Henson 7529be298c Fix typo - forEachMethodNoData
forEachMehtodNoData => forEachMethodNoData
2017-02-05 21:22:40 -05:00
Dominykas Blyžė eaba7875fc remove PROTECTION_PREFIX support 2016-11-28 11:16:55 +00:00
Nick Uraltsev d963368960 Adding get, head, and delete to defaults.headers 2016-10-29 22:57:53 -07:00
Rubén Norte b2745873a1 Moving default adapter to global defaults 2016-09-05 21:30:29 +02:00
Nick Uraltsev f20490eb6b Adding support for URLSearchParams 2016-05-07 12:26:28 -07:00
Nick Uraltsev fa9444e0ba Allow custom HTTP status code error ranges (#308)
Adding support for custom HTTP status code error ranges
2016-04-26 14:18:58 -06:00
Nick Uraltsev d23f9d5d47 Add support for Stream 2016-04-14 17:38:35 -07:00
bomsy fefa23a8dd Adding config option to restrict based on the size of the response co… 2016-03-25 23:50:52 +00:00
1000ch ca12c05882 fix typo 2016-02-02 21:09:25 +09:00
Matt Zabriskie f28a4a8248 Using more strict eslint rules 2015-12-14 20:06:57 -07:00
mzabriskie ffc0237a17 Adding support for timeout config
closes #56
2015-08-10 19:00:27 -06:00
mzabriskie 3c4dfe8a81 Making content-type header case insensitive
closes #89
2015-07-23 09:39:59 -07:00
mzabriskie 8365cbb789 Updating dependencies 2015-06-18 21:07:29 -06:00
mzabriskie 42fc3954d2 Fixing issue with FormData not being sent
closes #53
2015-04-08 12:46:03 -06:00
mzabriskie 9ddb607e3f Using JSON.parse unconditionally when transforming response string
closes #55
2015-04-07 20:53:46 -06:00
mzabriskie 60a82ef424 Changing to file level use strict statement 2015-03-18 17:21:15 -06:00
mzabriskie a98c61f458 Adding ESLint 2015-03-17 14:14:26 -06:00
mzabriskie f406b092fc Fixing failing tests 2014-09-22 10:47:41 -06:00
mzabriskie 77bed7c8ab Fixing issue #9 2014-09-21 16:57:07 -06:00
Mathieu Bruyen 095a204c5b Allow ArrayBuffer and related views as data
In order to push binary data under the form of ArrayBuffer and
its related views (Int8Array, ...) one needs not to stringify
those.

For the XHR adapter there is nothing to do as it natively supports
ArrayBuffer in req.send().

Node's http adapter supports only string or Buffer thus a
transformation to Buffer is required before setting content length
header.
2014-09-18 09:17:46 +02:00
mzabriskie e1aa04ccee Fixing issue #3 2014-09-16 18:23:31 -06:00
Matt Zabriskie 3ae6670f77 Fixing typo 2014-08-29 01:05:49 -06:00
Matt Zabriskie cec3482ff7 Moving utility functions into utils 2014-08-28 12:33:53 -06:00
Matt Zabriskie 9096d34186 Breaking up complexity of main axios file 2014-08-27 01:06:19 -06:00