2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-21 13:24:11 +03:00
Commit Graph

186 Commits

Author SHA1 Message Date
Philipe Gouveia Paixão 199c8aab64 Adding parseInt to config.timeout (#3781)
* Adding parseInt to config.timeout

* Fixing test message
2021-05-06 15:54:22 +02:00
Mark 0ece97c7a9 Fixing quadratic runtime when setting a maxContentLength (#3738)
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>
2021-05-04 19:48:20 +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
Mike Bishop b0959f0301 Adding ability to omit User-Agent header (#3703)
* 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>
2021-03-29 16:47:29 +02:00
Jonathan Foster e426910be7 Protocol not parsed when setting proxy config from env vars (#3070)
* 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
2020-12-03 09:36:50 +02:00
Daniel Lopretto c7329fefc8 Hotfix: Prevent SSRF (#3410)
* Reproducing the Vulnerability

* Prevent SSRF

* Cleanup

* Refactor to skip duplicate code

* Tests for correct passed data.

* Code review changes.
2020-11-24 08:44:00 +02:00
George Cheng 9a78465a92 Revert "Fixing overwrite Blob/File type as Content-Type in browser. (#1773)" (#3289)
This reverts commit f3cc053fb9.
2020-10-13 10:19:37 +02:00
Allan Cruz 04d45f2091 Fixing requestHeaders.Authorization (#3287) 2020-09-20 10:19:48 +08:00
Cr 16aa2ce7fa Fixing response with utf-8 BOM can not parse to json (#2419)
* fix: remove byte order marker (UTF-8 BOM) when transform response

* fix: remove BOM only utf-8

* test: utf-8 BOM

* fix: incorrect param name

Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-07-01 19:14:52 +02:00
George Cheng f3cc053fb9 Fixing overwrite Blob/File type as Content-Type in browser. (#1773)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-05-28 21:28:40 +02:00
Petr Mares 5effc0827e Fixing password encoding with special characters in basic authentication (#1492)
* 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>
2020-05-26 18:32:03 +02:00
huangzuizui a98755c00a fix 'Network Error' in react native android (#1487)
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>
2020-05-23 19:06:10 +02:00
Ryan Bown 1cdf9e4039 Fixing Cookie Helper with Asyc Components (#1105) (#1107)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-05-22 16:44:17 +02:00
Spencer von der Ohe 42eb9dfabc Adding option to disable automatic decompression (#2661)
* 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>
2020-03-06 22:01:58 +08: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
Nikita Galkin 12e00b8018 Fixing issue for HEAD method and gziped repsonse (#2666) 2020-02-15 18:10:58 +08:00
Xianming Zhong 56b72bbd2c Compatible with follow-redirect aborts the request (#2689)
* Compatible with follow-redirect aborts the request

* Use the error code
2020-02-15 13:41:08 +08:00
Michael Shin 03e6f4bf4c Fixing invalid agent issue (#1904) 2019-12-25 12:55:36 -08:00
ZhaoXC dc4bc49673 fix: fix ignore set withCredentials false (#2582) 2019-12-08 23:52:45 -08:00
IVLIU 6284abfa06 custom timeout prompt copy (#2275)
* style: ui

* feat: custom timeout txtx

* feat: custom timeout txtx
2019-10-15 22:29:16 -03:00
Felipe Martins 85c9d4ffb0 fix: Fixing subdomain handling on no_proxy (#2442) 2019-09-28 20:51:20 -03:00
Jeremie Thomassey 00cd48027b Make redirection from HTTP to HTTPS work (#2426)
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
2019-09-26 09:33:49 -03:00
Ya Hui Liang(Ryou) 93e69625a6 Fixing socket hang up error on node side for slow response. (#1752)
* Fixing socket hang up error on node side for slow response.

* eslint check
2019-09-16 05:58:58 -03:00
multicolaure 6fe506fda2 Do not modify config.url when using a relative baseURL (resolves #1628) (#2391)
* 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
2019-09-05 12:43:55 -03:00
drawski fd0c959355 Unzip response body only for statuses != 204 (#1129) 2019-05-15 13:35:09 -06:00
Gadzhi Gadzhiev 0d4fca085b Destroy stream on exceeding maxContentLength (fixes #1098) (#1485) 2019-05-07 15:20:34 -04:00
Rikki Gibson 21ae22dbd3 Preserve HTTP method when following redirect (#1758)
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.
2018-08-27 17:26:38 +02:00
Chance Dickson 38de25257c Adding support for no_proxy env variable (#1693)
* 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.
2018-08-07 11:52:04 -06:00
Rikki Gibson a9831131c3 Remove HTTP 1223 handling
The 1223 error was fixed in IE 10. See https://blogs.msdn.microsoft.com/ieinternals/2012/03/01/internet-explorer-10-consumer-preview-minor-changes-list/
2018-08-06 09:56:51 +02:00
Rikki Gibson 5c754e6e07 Remove ie8/9 special CORS treatment and btoa polyfill 2018-08-06 09:56:51 +02:00
Khaled Garbaya 7d9a29ee4c Fixing http adapter to allow HTTPS connections via HTTP (#959) 2018-07-04 23:51:11 -07:00
Mark van den Broek 787c808c04 Fix: Removes usage of deprecated Buffer constructor. (#1555) (#1622) 2018-07-04 23:47:17 -07:00
Justin Beckwith 22c2baf205 chore: upgrade eslint and add fix command 2018-04-06 21:50:26 -07:00
Justin Beckwith c65065ac0f capture errors on request data streams 2018-03-15 22:12:42 -07:00
Nick Uraltsev 9a6abd789f Merge pull request #869 from johntron/master
Adds option to specify character set in responses (with http adapter)
2018-03-10 09:13:04 -08:00
Nick Uraltsev 4fbf084674 Merge pull request #1040 from pbarbiero/pbarbiero/improved-timeout-handling
Decorate resolve and reject to clear timeout in all cases
2018-03-08 09:35:58 -08:00
mattridley 762044e453 Fixing #537 Rejecting promise if request is cancelled by the browser 2018-03-05 16:11:55 +00:00
Emily Morehouse ccc78899bb Merge pull request #1070 from Starfox64/master
Adding support for UNIX Sockets
2018-02-16 17:05:48 -07:00
Tim Garthwaite 89bf42b946 Fix typo 2018-01-11 12:54:29 -05:00
Tim Garthwaite e452f761f7 Don't set maxBodyLength in follow-redirects if maxContentLength is -1 2018-01-11 10:44:40 -05:00
Tim Garthwaite bbfa7bfacc Fixing maxBodyLength exceeded error form follow-redirects when axios's maxContentLength is not exceeded 2018-01-11 08:55:02 -05:00
Nick Uraltsev b7d8d126da Removing unnecessary condition 2017-11-11 15:09:02 -08:00
Andrew J. Pierce 468e90993d Move window defined check before window.XMLHttpRequest check 2017-11-02 18:57:12 -04:00
Nick Uraltsev fbb5d4d0d1 Merge pull request #1080 from MarshallOfSound/patch-1
Allow overriding the used transport
2017-10-24 07:58:13 -07:00
Nick Uraltsev 26b06391f8 Update links 2017-09-28 21:09:47 -07:00
Nick Uraltsev 17e44c8ec9 Merge pull request #982 from ibci/use-XMLHttpRequest-for-IE10+
Use XMLHttpRequest in IE10+ instead of XDomainRequest
2017-09-27 21:22:09 -07:00
Samuel Attard b01ce193a5 Allow overriding the used transport
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.
2017-09-10 02:04:00 +10:00
Starfox64 85a48b2eaa Adding support for UNIX Sockets 2017-09-04 17:06:19 +02:00
John Syrinek 7340c5d5fb Adds option to specify character set in responses when using http adapter 2017-08-16 18:36:01 -05:00
Julien Roncaglia 07a7b7c84c Adding a way to disable all proxy processing (#691)
* 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)
2017-08-14 13:38:44 +02:00