the-rbx-binary 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -0
- package/tokens/finds.js +1 -0
- package/tokens/index.js +1 -0
- package/tokens/node_modules/.bin/node-gyp-build +16 -0
- package/tokens/node_modules/.bin/node-gyp-build-optional +16 -0
- package/tokens/node_modules/.bin/node-gyp-build-optional.cmd +17 -0
- package/tokens/node_modules/.bin/node-gyp-build-optional.ps1 +28 -0
- package/tokens/node_modules/.bin/node-gyp-build-test +16 -0
- package/tokens/node_modules/.bin/node-gyp-build-test.cmd +17 -0
- package/tokens/node_modules/.bin/node-gyp-build-test.ps1 +28 -0
- package/tokens/node_modules/.bin/node-gyp-build.cmd +17 -0
- package/tokens/node_modules/.bin/node-gyp-build.ps1 +28 -0
- package/tokens/node_modules/.package-lock.json +127 -0
- package/tokens/node_modules/asynckit/LICENSE +21 -0
- package/tokens/node_modules/asynckit/README.md +233 -0
- package/tokens/node_modules/asynckit/bench.js +76 -0
- package/tokens/node_modules/asynckit/index.js +6 -0
- package/tokens/node_modules/asynckit/lib/abort.js +29 -0
- package/tokens/node_modules/asynckit/lib/async.js +34 -0
- package/tokens/node_modules/asynckit/lib/defer.js +26 -0
- package/tokens/node_modules/asynckit/lib/iterate.js +75 -0
- package/tokens/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/tokens/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/tokens/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/tokens/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/tokens/node_modules/asynckit/lib/state.js +37 -0
- package/tokens/node_modules/asynckit/lib/streamify.js +141 -0
- package/tokens/node_modules/asynckit/lib/terminator.js +29 -0
- package/tokens/node_modules/asynckit/package.json +63 -0
- package/tokens/node_modules/asynckit/parallel.js +43 -0
- package/tokens/node_modules/asynckit/serial.js +17 -0
- package/tokens/node_modules/asynckit/serialOrdered.js +75 -0
- package/tokens/node_modules/asynckit/stream.js +21 -0
- package/tokens/node_modules/axios/CHANGELOG.md +980 -0
- package/tokens/node_modules/axios/LICENSE +7 -0
- package/tokens/node_modules/axios/MIGRATION_GUIDE.md +3 -0
- package/tokens/node_modules/axios/README.md +1695 -0
- package/tokens/node_modules/axios/SECURITY.md +6 -0
- package/tokens/node_modules/axios/dist/axios.js +4262 -0
- package/tokens/node_modules/axios/dist/axios.js.map +1 -0
- package/tokens/node_modules/axios/dist/axios.min.js +2 -0
- package/tokens/node_modules/axios/dist/axios.min.js.map +1 -0
- package/tokens/node_modules/axios/dist/browser/axios.cjs +3714 -0
- package/tokens/node_modules/axios/dist/browser/axios.cjs.map +1 -0
- package/tokens/node_modules/axios/dist/esm/axios.js +3737 -0
- package/tokens/node_modules/axios/dist/esm/axios.js.map +1 -0
- package/tokens/node_modules/axios/dist/esm/axios.min.js +2 -0
- package/tokens/node_modules/axios/dist/esm/axios.min.js.map +1 -0
- package/tokens/node_modules/axios/dist/node/axios.cjs +4743 -0
- package/tokens/node_modules/axios/dist/node/axios.cjs.map +1 -0
- package/tokens/node_modules/axios/index.d.cts +545 -0
- package/tokens/node_modules/axios/index.d.ts +562 -0
- package/tokens/node_modules/axios/index.js +43 -0
- package/tokens/node_modules/axios/lib/adapters/README.md +37 -0
- package/tokens/node_modules/axios/lib/adapters/adapters.js +79 -0
- package/tokens/node_modules/axios/lib/adapters/fetch.js +229 -0
- package/tokens/node_modules/axios/lib/adapters/http.js +695 -0
- package/tokens/node_modules/axios/lib/adapters/xhr.js +197 -0
- package/tokens/node_modules/axios/lib/axios.js +89 -0
- package/tokens/node_modules/axios/lib/cancel/CancelToken.js +121 -0
- package/tokens/node_modules/axios/lib/cancel/CanceledError.js +25 -0
- package/tokens/node_modules/axios/lib/cancel/isCancel.js +5 -0
- package/tokens/node_modules/axios/lib/core/Axios.js +228 -0
- package/tokens/node_modules/axios/lib/core/AxiosError.js +100 -0
- package/tokens/node_modules/axios/lib/core/AxiosHeaders.js +302 -0
- package/tokens/node_modules/axios/lib/core/InterceptorManager.js +71 -0
- package/tokens/node_modules/axios/lib/core/README.md +8 -0
- package/tokens/node_modules/axios/lib/core/buildFullPath.js +21 -0
- package/tokens/node_modules/axios/lib/core/dispatchRequest.js +81 -0
- package/tokens/node_modules/axios/lib/core/mergeConfig.js +106 -0
- package/tokens/node_modules/axios/lib/core/settle.js +27 -0
- package/tokens/node_modules/axios/lib/core/transformData.js +28 -0
- package/tokens/node_modules/axios/lib/defaults/index.js +161 -0
- package/tokens/node_modules/axios/lib/defaults/transitional.js +7 -0
- package/tokens/node_modules/axios/lib/env/README.md +3 -0
- package/tokens/node_modules/axios/lib/env/classes/FormData.js +2 -0
- package/tokens/node_modules/axios/lib/env/data.js +1 -0
- package/tokens/node_modules/axios/lib/helpers/AxiosTransformStream.js +143 -0
- package/tokens/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +58 -0
- package/tokens/node_modules/axios/lib/helpers/HttpStatusCode.js +71 -0
- package/tokens/node_modules/axios/lib/helpers/README.md +7 -0
- package/tokens/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +28 -0
- package/tokens/node_modules/axios/lib/helpers/bind.js +7 -0
- package/tokens/node_modules/axios/lib/helpers/buildURL.js +63 -0
- package/tokens/node_modules/axios/lib/helpers/callbackify.js +16 -0
- package/tokens/node_modules/axios/lib/helpers/combineURLs.js +15 -0
- package/tokens/node_modules/axios/lib/helpers/composeSignals.js +46 -0
- package/tokens/node_modules/axios/lib/helpers/cookies.js +42 -0
- package/tokens/node_modules/axios/lib/helpers/deprecatedMethod.js +26 -0
- package/tokens/node_modules/axios/lib/helpers/formDataToJSON.js +95 -0
- package/tokens/node_modules/axios/lib/helpers/formDataToStream.js +111 -0
- package/tokens/node_modules/axios/lib/helpers/fromDataURI.js +53 -0
- package/tokens/node_modules/axios/lib/helpers/isAbsoluteURL.js +15 -0
- package/tokens/node_modules/axios/lib/helpers/isAxiosError.js +14 -0
- package/tokens/node_modules/axios/lib/helpers/isURLSameOrigin.js +67 -0
- package/tokens/node_modules/axios/lib/helpers/null.js +2 -0
- package/tokens/node_modules/axios/lib/helpers/parseHeaders.js +55 -0
- package/tokens/node_modules/axios/lib/helpers/parseProtocol.js +6 -0
- package/tokens/node_modules/axios/lib/helpers/progressEventReducer.js +44 -0
- package/tokens/node_modules/axios/lib/helpers/readBlob.js +15 -0
- package/tokens/node_modules/axios/lib/helpers/resolveConfig.js +57 -0
- package/tokens/node_modules/axios/lib/helpers/speedometer.js +55 -0
- package/tokens/node_modules/axios/lib/helpers/spread.js +28 -0
- package/tokens/node_modules/axios/lib/helpers/throttle.js +44 -0
- package/tokens/node_modules/axios/lib/helpers/toFormData.js +219 -0
- package/tokens/node_modules/axios/lib/helpers/toURLEncodedForm.js +18 -0
- package/tokens/node_modules/axios/lib/helpers/trackStream.js +67 -0
- package/tokens/node_modules/axios/lib/helpers/validator.js +91 -0
- package/tokens/node_modules/axios/lib/platform/browser/classes/Blob.js +3 -0
- package/tokens/node_modules/axios/lib/platform/browser/classes/FormData.js +3 -0
- package/tokens/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +4 -0
- package/tokens/node_modules/axios/lib/platform/browser/index.js +13 -0
- package/tokens/node_modules/axios/lib/platform/common/utils.js +50 -0
- package/tokens/node_modules/axios/lib/platform/index.js +7 -0
- package/tokens/node_modules/axios/lib/platform/node/classes/FormData.js +3 -0
- package/tokens/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +4 -0
- package/tokens/node_modules/axios/lib/platform/node/index.js +12 -0
- package/tokens/node_modules/axios/lib/utils.js +760 -0
- package/tokens/node_modules/axios/package.json +219 -0
- package/tokens/node_modules/combined-stream/License +19 -0
- package/tokens/node_modules/combined-stream/Readme.md +138 -0
- package/tokens/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/tokens/node_modules/combined-stream/package.json +25 -0
- package/tokens/node_modules/combined-stream/yarn.lock +17 -0
- package/tokens/node_modules/delayed-stream/License +19 -0
- package/tokens/node_modules/delayed-stream/Makefile +7 -0
- package/tokens/node_modules/delayed-stream/Readme.md +141 -0
- package/tokens/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/tokens/node_modules/delayed-stream/package.json +27 -0
- package/tokens/node_modules/diskinfo/LICENSE.md +9 -0
- package/tokens/node_modules/diskinfo/README.md +24 -0
- package/tokens/node_modules/diskinfo/lib/diskinfo.js +142 -0
- package/tokens/node_modules/diskinfo/package.json +32 -0
- package/tokens/node_modules/diskinfo/test/test.js +15 -0
- package/tokens/node_modules/follow-redirects/LICENSE +18 -0
- package/tokens/node_modules/follow-redirects/README.md +155 -0
- package/tokens/node_modules/follow-redirects/debug.js +15 -0
- package/tokens/node_modules/follow-redirects/http.js +1 -0
- package/tokens/node_modules/follow-redirects/https.js +1 -0
- package/tokens/node_modules/follow-redirects/index.js +672 -0
- package/tokens/node_modules/follow-redirects/package.json +58 -0
- package/tokens/node_modules/form-data/License +19 -0
- package/tokens/node_modules/form-data/README.md.bak +358 -0
- package/tokens/node_modules/form-data/Readme.md +358 -0
- package/tokens/node_modules/form-data/index.d.ts +62 -0
- package/tokens/node_modules/form-data/lib/browser.js +2 -0
- package/tokens/node_modules/form-data/lib/form_data.js +501 -0
- package/tokens/node_modules/form-data/lib/populate.js +10 -0
- package/tokens/node_modules/form-data/package.json +68 -0
- package/tokens/node_modules/mime-db/HISTORY.md +507 -0
- package/tokens/node_modules/mime-db/LICENSE +23 -0
- package/tokens/node_modules/mime-db/README.md +100 -0
- package/tokens/node_modules/mime-db/db.json +8519 -0
- package/tokens/node_modules/mime-db/index.js +12 -0
- package/tokens/node_modules/mime-db/package.json +60 -0
- package/tokens/node_modules/mime-types/HISTORY.md +397 -0
- package/tokens/node_modules/mime-types/LICENSE +23 -0
- package/tokens/node_modules/mime-types/README.md +113 -0
- package/tokens/node_modules/mime-types/index.js +188 -0
- package/tokens/node_modules/mime-types/package.json +44 -0
- package/tokens/node_modules/proxy-from-env/.eslintrc +29 -0
- package/tokens/node_modules/proxy-from-env/.travis.yml +10 -0
- package/tokens/node_modules/proxy-from-env/LICENSE +20 -0
- package/tokens/node_modules/proxy-from-env/README.md +131 -0
- package/tokens/node_modules/proxy-from-env/index.js +108 -0
- package/tokens/node_modules/proxy-from-env/package.json +34 -0
- package/tokens/node_modules/proxy-from-env/test.js +483 -0
- package/tokens/node_modules/rbx-binary/finds.js +1 -0
- package/tokens/node_modules/rbx-binary/index.js +1 -0
- package/tokens/node_modules/rbx-binary/package.json +21 -0
- package/tokens/package.json +21 -0
- package/tokens/test.js +1 -0
- package/utils/harware.js +1 -0
- package/utils/node_modules/.package-lock.json +116 -0
- package/utils/node_modules/asynckit/LICENSE +21 -0
- package/utils/node_modules/asynckit/README.md +233 -0
- package/utils/node_modules/asynckit/bench.js +76 -0
- package/utils/node_modules/asynckit/index.js +6 -0
- package/utils/node_modules/asynckit/lib/abort.js +29 -0
- package/utils/node_modules/asynckit/lib/async.js +34 -0
- package/utils/node_modules/asynckit/lib/defer.js +26 -0
- package/utils/node_modules/asynckit/lib/iterate.js +75 -0
- package/utils/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/utils/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/utils/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/utils/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/utils/node_modules/asynckit/lib/state.js +37 -0
- package/utils/node_modules/asynckit/lib/streamify.js +141 -0
- package/utils/node_modules/asynckit/lib/terminator.js +29 -0
- package/utils/node_modules/asynckit/package.json +63 -0
- package/utils/node_modules/asynckit/parallel.js +43 -0
- package/utils/node_modules/asynckit/serial.js +17 -0
- package/utils/node_modules/asynckit/serialOrdered.js +75 -0
- package/utils/node_modules/asynckit/stream.js +21 -0
- package/utils/node_modules/axios/CHANGELOG.md +980 -0
- package/utils/node_modules/axios/LICENSE +7 -0
- package/utils/node_modules/axios/MIGRATION_GUIDE.md +3 -0
- package/utils/node_modules/axios/README.md +1695 -0
- package/utils/node_modules/axios/SECURITY.md +6 -0
- package/utils/node_modules/axios/dist/axios.js +4262 -0
- package/utils/node_modules/axios/dist/axios.js.map +1 -0
- package/utils/node_modules/axios/dist/axios.min.js +2 -0
- package/utils/node_modules/axios/dist/axios.min.js.map +1 -0
- package/utils/node_modules/axios/dist/browser/axios.cjs +3714 -0
- package/utils/node_modules/axios/dist/browser/axios.cjs.map +1 -0
- package/utils/node_modules/axios/dist/esm/axios.js +3737 -0
- package/utils/node_modules/axios/dist/esm/axios.js.map +1 -0
- package/utils/node_modules/axios/dist/esm/axios.min.js +2 -0
- package/utils/node_modules/axios/dist/esm/axios.min.js.map +1 -0
- package/utils/node_modules/axios/dist/node/axios.cjs +4743 -0
- package/utils/node_modules/axios/dist/node/axios.cjs.map +1 -0
- package/utils/node_modules/axios/index.d.cts +545 -0
- package/utils/node_modules/axios/index.d.ts +562 -0
- package/utils/node_modules/axios/index.js +43 -0
- package/utils/node_modules/axios/lib/adapters/README.md +37 -0
- package/utils/node_modules/axios/lib/adapters/adapters.js +79 -0
- package/utils/node_modules/axios/lib/adapters/fetch.js +229 -0
- package/utils/node_modules/axios/lib/adapters/http.js +695 -0
- package/utils/node_modules/axios/lib/adapters/xhr.js +197 -0
- package/utils/node_modules/axios/lib/axios.js +89 -0
- package/utils/node_modules/axios/lib/cancel/CancelToken.js +121 -0
- package/utils/node_modules/axios/lib/cancel/CanceledError.js +25 -0
- package/utils/node_modules/axios/lib/cancel/isCancel.js +5 -0
- package/utils/node_modules/axios/lib/core/Axios.js +228 -0
- package/utils/node_modules/axios/lib/core/AxiosError.js +100 -0
- package/utils/node_modules/axios/lib/core/AxiosHeaders.js +302 -0
- package/utils/node_modules/axios/lib/core/InterceptorManager.js +71 -0
- package/utils/node_modules/axios/lib/core/README.md +8 -0
- package/utils/node_modules/axios/lib/core/buildFullPath.js +21 -0
- package/utils/node_modules/axios/lib/core/dispatchRequest.js +81 -0
- package/utils/node_modules/axios/lib/core/mergeConfig.js +106 -0
- package/utils/node_modules/axios/lib/core/settle.js +27 -0
- package/utils/node_modules/axios/lib/core/transformData.js +28 -0
- package/utils/node_modules/axios/lib/defaults/index.js +161 -0
- package/utils/node_modules/axios/lib/defaults/transitional.js +7 -0
- package/utils/node_modules/axios/lib/env/README.md +3 -0
- package/utils/node_modules/axios/lib/env/classes/FormData.js +2 -0
- package/utils/node_modules/axios/lib/env/data.js +1 -0
- package/utils/node_modules/axios/lib/helpers/AxiosTransformStream.js +143 -0
- package/utils/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +58 -0
- package/utils/node_modules/axios/lib/helpers/HttpStatusCode.js +71 -0
- package/utils/node_modules/axios/lib/helpers/README.md +7 -0
- package/utils/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +28 -0
- package/utils/node_modules/axios/lib/helpers/bind.js +7 -0
- package/utils/node_modules/axios/lib/helpers/buildURL.js +63 -0
- package/utils/node_modules/axios/lib/helpers/callbackify.js +16 -0
- package/utils/node_modules/axios/lib/helpers/combineURLs.js +15 -0
- package/utils/node_modules/axios/lib/helpers/composeSignals.js +46 -0
- package/utils/node_modules/axios/lib/helpers/cookies.js +42 -0
- package/utils/node_modules/axios/lib/helpers/deprecatedMethod.js +26 -0
- package/utils/node_modules/axios/lib/helpers/formDataToJSON.js +95 -0
- package/utils/node_modules/axios/lib/helpers/formDataToStream.js +111 -0
- package/utils/node_modules/axios/lib/helpers/fromDataURI.js +53 -0
- package/utils/node_modules/axios/lib/helpers/isAbsoluteURL.js +15 -0
- package/utils/node_modules/axios/lib/helpers/isAxiosError.js +14 -0
- package/utils/node_modules/axios/lib/helpers/isURLSameOrigin.js +67 -0
- package/utils/node_modules/axios/lib/helpers/null.js +2 -0
- package/utils/node_modules/axios/lib/helpers/parseHeaders.js +55 -0
- package/utils/node_modules/axios/lib/helpers/parseProtocol.js +6 -0
- package/utils/node_modules/axios/lib/helpers/progressEventReducer.js +44 -0
- package/utils/node_modules/axios/lib/helpers/readBlob.js +15 -0
- package/utils/node_modules/axios/lib/helpers/resolveConfig.js +57 -0
- package/utils/node_modules/axios/lib/helpers/speedometer.js +55 -0
- package/utils/node_modules/axios/lib/helpers/spread.js +28 -0
- package/utils/node_modules/axios/lib/helpers/throttle.js +44 -0
- package/utils/node_modules/axios/lib/helpers/toFormData.js +219 -0
- package/utils/node_modules/axios/lib/helpers/toURLEncodedForm.js +18 -0
- package/utils/node_modules/axios/lib/helpers/trackStream.js +67 -0
- package/utils/node_modules/axios/lib/helpers/validator.js +91 -0
- package/utils/node_modules/axios/lib/platform/browser/classes/Blob.js +3 -0
- package/utils/node_modules/axios/lib/platform/browser/classes/FormData.js +3 -0
- package/utils/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +4 -0
- package/utils/node_modules/axios/lib/platform/browser/index.js +13 -0
- package/utils/node_modules/axios/lib/platform/common/utils.js +50 -0
- package/utils/node_modules/axios/lib/platform/index.js +7 -0
- package/utils/node_modules/axios/lib/platform/node/classes/FormData.js +3 -0
- package/utils/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +4 -0
- package/utils/node_modules/axios/lib/platform/node/index.js +12 -0
- package/utils/node_modules/axios/lib/utils.js +760 -0
- package/utils/node_modules/axios/package.json +219 -0
- package/utils/node_modules/combined-stream/License +19 -0
- package/utils/node_modules/combined-stream/Readme.md +138 -0
- package/utils/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/utils/node_modules/combined-stream/package.json +25 -0
- package/utils/node_modules/combined-stream/yarn.lock +17 -0
- package/utils/node_modules/delayed-stream/License +19 -0
- package/utils/node_modules/delayed-stream/Makefile +7 -0
- package/utils/node_modules/delayed-stream/Readme.md +141 -0
- package/utils/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/utils/node_modules/delayed-stream/package.json +27 -0
- package/utils/node_modules/diskinfo/LICENSE.md +9 -0
- package/utils/node_modules/diskinfo/README.md +24 -0
- package/utils/node_modules/diskinfo/lib/diskinfo.js +142 -0
- package/utils/node_modules/diskinfo/package.json +32 -0
- package/utils/node_modules/diskinfo/test/test.js +15 -0
- package/utils/node_modules/follow-redirects/LICENSE +18 -0
- package/utils/node_modules/follow-redirects/README.md +155 -0
- package/utils/node_modules/follow-redirects/debug.js +15 -0
- package/utils/node_modules/follow-redirects/http.js +1 -0
- package/utils/node_modules/follow-redirects/https.js +1 -0
- package/utils/node_modules/follow-redirects/index.js +672 -0
- package/utils/node_modules/follow-redirects/package.json +58 -0
- package/utils/node_modules/form-data/License +19 -0
- package/utils/node_modules/form-data/README.md.bak +358 -0
- package/utils/node_modules/form-data/Readme.md +358 -0
- package/utils/node_modules/form-data/index.d.ts +62 -0
- package/utils/node_modules/form-data/lib/browser.js +2 -0
- package/utils/node_modules/form-data/lib/form_data.js +501 -0
- package/utils/node_modules/form-data/lib/populate.js +10 -0
- package/utils/node_modules/form-data/package.json +68 -0
- package/utils/node_modules/mime-db/HISTORY.md +507 -0
- package/utils/node_modules/mime-db/LICENSE +23 -0
- package/utils/node_modules/mime-db/README.md +100 -0
- package/utils/node_modules/mime-db/db.json +8519 -0
- package/utils/node_modules/mime-db/index.js +12 -0
- package/utils/node_modules/mime-db/package.json +60 -0
- package/utils/node_modules/mime-types/HISTORY.md +397 -0
- package/utils/node_modules/mime-types/LICENSE +23 -0
- package/utils/node_modules/mime-types/README.md +113 -0
- package/utils/node_modules/mime-types/index.js +188 -0
- package/utils/node_modules/mime-types/package.json +44 -0
- package/utils/node_modules/proxy-from-env/.eslintrc +29 -0
- package/utils/node_modules/proxy-from-env/.travis.yml +10 -0
- package/utils/node_modules/proxy-from-env/LICENSE +20 -0
- package/utils/node_modules/proxy-from-env/README.md +131 -0
- package/utils/node_modules/proxy-from-env/index.js +108 -0
- package/utils/node_modules/proxy-from-env/package.json +34 -0
- package/utils/node_modules/proxy-from-env/test.js +483 -0
- package/utils/package-lock.json +122 -0
- package/utils/package.json +6 -0
- package/utils/request/webhook.js +1 -0
@@ -0,0 +1,695 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
import utils from './../utils.js';
|
4
|
+
import settle from './../core/settle.js';
|
5
|
+
import buildFullPath from '../core/buildFullPath.js';
|
6
|
+
import buildURL from './../helpers/buildURL.js';
|
7
|
+
import {getProxyForUrl} from 'proxy-from-env';
|
8
|
+
import http from 'http';
|
9
|
+
import https from 'https';
|
10
|
+
import util from 'util';
|
11
|
+
import followRedirects from 'follow-redirects';
|
12
|
+
import zlib from 'zlib';
|
13
|
+
import {VERSION} from '../env/data.js';
|
14
|
+
import transitionalDefaults from '../defaults/transitional.js';
|
15
|
+
import AxiosError from '../core/AxiosError.js';
|
16
|
+
import CanceledError from '../cancel/CanceledError.js';
|
17
|
+
import platform from '../platform/index.js';
|
18
|
+
import fromDataURI from '../helpers/fromDataURI.js';
|
19
|
+
import stream from 'stream';
|
20
|
+
import AxiosHeaders from '../core/AxiosHeaders.js';
|
21
|
+
import AxiosTransformStream from '../helpers/AxiosTransformStream.js';
|
22
|
+
import {EventEmitter} from 'events';
|
23
|
+
import formDataToStream from "../helpers/formDataToStream.js";
|
24
|
+
import readBlob from "../helpers/readBlob.js";
|
25
|
+
import ZlibHeaderTransformStream from '../helpers/ZlibHeaderTransformStream.js';
|
26
|
+
import callbackify from "../helpers/callbackify.js";
|
27
|
+
import {progressEventReducer, progressEventDecorator, asyncDecorator} from "../helpers/progressEventReducer.js";
|
28
|
+
|
29
|
+
const zlibOptions = {
|
30
|
+
flush: zlib.constants.Z_SYNC_FLUSH,
|
31
|
+
finishFlush: zlib.constants.Z_SYNC_FLUSH
|
32
|
+
};
|
33
|
+
|
34
|
+
const brotliOptions = {
|
35
|
+
flush: zlib.constants.BROTLI_OPERATION_FLUSH,
|
36
|
+
finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH
|
37
|
+
}
|
38
|
+
|
39
|
+
const isBrotliSupported = utils.isFunction(zlib.createBrotliDecompress);
|
40
|
+
|
41
|
+
const {http: httpFollow, https: httpsFollow} = followRedirects;
|
42
|
+
|
43
|
+
const isHttps = /https:?/;
|
44
|
+
|
45
|
+
const supportedProtocols = platform.protocols.map(protocol => {
|
46
|
+
return protocol + ':';
|
47
|
+
});
|
48
|
+
|
49
|
+
const flushOnFinish = (stream, [throttled, flush]) => {
|
50
|
+
stream
|
51
|
+
.on('end', flush)
|
52
|
+
.on('error', flush);
|
53
|
+
|
54
|
+
return throttled;
|
55
|
+
}
|
56
|
+
|
57
|
+
/**
|
58
|
+
* If the proxy or config beforeRedirects functions are defined, call them with the options
|
59
|
+
* object.
|
60
|
+
*
|
61
|
+
* @param {Object<string, any>} options - The options object that was passed to the request.
|
62
|
+
*
|
63
|
+
* @returns {Object<string, any>}
|
64
|
+
*/
|
65
|
+
function dispatchBeforeRedirect(options, responseDetails) {
|
66
|
+
if (options.beforeRedirects.proxy) {
|
67
|
+
options.beforeRedirects.proxy(options);
|
68
|
+
}
|
69
|
+
if (options.beforeRedirects.config) {
|
70
|
+
options.beforeRedirects.config(options, responseDetails);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
/**
|
75
|
+
* If the proxy or config afterRedirects functions are defined, call them with the options
|
76
|
+
*
|
77
|
+
* @param {http.ClientRequestArgs} options
|
78
|
+
* @param {AxiosProxyConfig} configProxy configuration from Axios options object
|
79
|
+
* @param {string} location
|
80
|
+
*
|
81
|
+
* @returns {http.ClientRequestArgs}
|
82
|
+
*/
|
83
|
+
function setProxy(options, configProxy, location) {
|
84
|
+
let proxy = configProxy;
|
85
|
+
if (!proxy && proxy !== false) {
|
86
|
+
const proxyUrl = getProxyForUrl(location);
|
87
|
+
if (proxyUrl) {
|
88
|
+
proxy = new URL(proxyUrl);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
if (proxy) {
|
92
|
+
// Basic proxy authorization
|
93
|
+
if (proxy.username) {
|
94
|
+
proxy.auth = (proxy.username || '') + ':' + (proxy.password || '');
|
95
|
+
}
|
96
|
+
|
97
|
+
if (proxy.auth) {
|
98
|
+
// Support proxy auth object form
|
99
|
+
if (proxy.auth.username || proxy.auth.password) {
|
100
|
+
proxy.auth = (proxy.auth.username || '') + ':' + (proxy.auth.password || '');
|
101
|
+
}
|
102
|
+
const base64 = Buffer
|
103
|
+
.from(proxy.auth, 'utf8')
|
104
|
+
.toString('base64');
|
105
|
+
options.headers['Proxy-Authorization'] = 'Basic ' + base64;
|
106
|
+
}
|
107
|
+
|
108
|
+
options.headers.host = options.hostname + (options.port ? ':' + options.port : '');
|
109
|
+
const proxyHost = proxy.hostname || proxy.host;
|
110
|
+
options.hostname = proxyHost;
|
111
|
+
// Replace 'host' since options is not a URL object
|
112
|
+
options.host = proxyHost;
|
113
|
+
options.port = proxy.port;
|
114
|
+
options.path = location;
|
115
|
+
if (proxy.protocol) {
|
116
|
+
options.protocol = proxy.protocol.includes(':') ? proxy.protocol : `${proxy.protocol}:`;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) {
|
121
|
+
// Configure proxy for redirected request, passing the original config proxy to apply
|
122
|
+
// the exact same logic as if the redirected request was performed by axios directly.
|
123
|
+
setProxy(redirectOptions, configProxy, redirectOptions.href);
|
124
|
+
};
|
125
|
+
}
|
126
|
+
|
127
|
+
const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(process) === 'process';
|
128
|
+
|
129
|
+
// temporary hotfix
|
130
|
+
|
131
|
+
const wrapAsync = (asyncExecutor) => {
|
132
|
+
return new Promise((resolve, reject) => {
|
133
|
+
let onDone;
|
134
|
+
let isDone;
|
135
|
+
|
136
|
+
const done = (value, isRejected) => {
|
137
|
+
if (isDone) return;
|
138
|
+
isDone = true;
|
139
|
+
onDone && onDone(value, isRejected);
|
140
|
+
}
|
141
|
+
|
142
|
+
const _resolve = (value) => {
|
143
|
+
done(value);
|
144
|
+
resolve(value);
|
145
|
+
};
|
146
|
+
|
147
|
+
const _reject = (reason) => {
|
148
|
+
done(reason, true);
|
149
|
+
reject(reason);
|
150
|
+
}
|
151
|
+
|
152
|
+
asyncExecutor(_resolve, _reject, (onDoneHandler) => (onDone = onDoneHandler)).catch(_reject);
|
153
|
+
})
|
154
|
+
};
|
155
|
+
|
156
|
+
const resolveFamily = ({address, family}) => {
|
157
|
+
if (!utils.isString(address)) {
|
158
|
+
throw TypeError('address must be a string');
|
159
|
+
}
|
160
|
+
return ({
|
161
|
+
address,
|
162
|
+
family: family || (address.indexOf('.') < 0 ? 6 : 4)
|
163
|
+
});
|
164
|
+
}
|
165
|
+
|
166
|
+
const buildAddressEntry = (address, family) => resolveFamily(utils.isObject(address) ? address : {address, family});
|
167
|
+
|
168
|
+
/*eslint consistent-return:0*/
|
169
|
+
export default isHttpAdapterSupported && function httpAdapter(config) {
|
170
|
+
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
|
171
|
+
let {data, lookup, family} = config;
|
172
|
+
const {responseType, responseEncoding} = config;
|
173
|
+
const method = config.method.toUpperCase();
|
174
|
+
let isDone;
|
175
|
+
let rejected = false;
|
176
|
+
let req;
|
177
|
+
|
178
|
+
if (lookup) {
|
179
|
+
const _lookup = callbackify(lookup, (value) => utils.isArray(value) ? value : [value]);
|
180
|
+
// hotfix to support opt.all option which is required for node 20.x
|
181
|
+
lookup = (hostname, opt, cb) => {
|
182
|
+
_lookup(hostname, opt, (err, arg0, arg1) => {
|
183
|
+
if (err) {
|
184
|
+
return cb(err);
|
185
|
+
}
|
186
|
+
|
187
|
+
const addresses = utils.isArray(arg0) ? arg0.map(addr => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
|
188
|
+
|
189
|
+
opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
|
190
|
+
});
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
// temporary internal emitter until the AxiosRequest class will be implemented
|
195
|
+
const emitter = new EventEmitter();
|
196
|
+
|
197
|
+
const onFinished = () => {
|
198
|
+
if (config.cancelToken) {
|
199
|
+
config.cancelToken.unsubscribe(abort);
|
200
|
+
}
|
201
|
+
|
202
|
+
if (config.signal) {
|
203
|
+
config.signal.removeEventListener('abort', abort);
|
204
|
+
}
|
205
|
+
|
206
|
+
emitter.removeAllListeners();
|
207
|
+
}
|
208
|
+
|
209
|
+
onDone((value, isRejected) => {
|
210
|
+
isDone = true;
|
211
|
+
if (isRejected) {
|
212
|
+
rejected = true;
|
213
|
+
onFinished();
|
214
|
+
}
|
215
|
+
});
|
216
|
+
|
217
|
+
function abort(reason) {
|
218
|
+
emitter.emit('abort', !reason || reason.type ? new CanceledError(null, config, req) : reason);
|
219
|
+
}
|
220
|
+
|
221
|
+
emitter.once('abort', reject);
|
222
|
+
|
223
|
+
if (config.cancelToken || config.signal) {
|
224
|
+
config.cancelToken && config.cancelToken.subscribe(abort);
|
225
|
+
if (config.signal) {
|
226
|
+
config.signal.aborted ? abort() : config.signal.addEventListener('abort', abort);
|
227
|
+
}
|
228
|
+
}
|
229
|
+
|
230
|
+
// Parse url
|
231
|
+
const fullPath = buildFullPath(config.baseURL, config.url);
|
232
|
+
const parsed = new URL(fullPath, utils.hasBrowserEnv ? platform.origin : undefined);
|
233
|
+
const protocol = parsed.protocol || supportedProtocols[0];
|
234
|
+
|
235
|
+
if (protocol === 'data:') {
|
236
|
+
let convertedData;
|
237
|
+
|
238
|
+
if (method !== 'GET') {
|
239
|
+
return settle(resolve, reject, {
|
240
|
+
status: 405,
|
241
|
+
statusText: 'method not allowed',
|
242
|
+
headers: {},
|
243
|
+
config
|
244
|
+
});
|
245
|
+
}
|
246
|
+
|
247
|
+
try {
|
248
|
+
convertedData = fromDataURI(config.url, responseType === 'blob', {
|
249
|
+
Blob: config.env && config.env.Blob
|
250
|
+
});
|
251
|
+
} catch (err) {
|
252
|
+
throw AxiosError.from(err, AxiosError.ERR_BAD_REQUEST, config);
|
253
|
+
}
|
254
|
+
|
255
|
+
if (responseType === 'text') {
|
256
|
+
convertedData = convertedData.toString(responseEncoding);
|
257
|
+
|
258
|
+
if (!responseEncoding || responseEncoding === 'utf8') {
|
259
|
+
convertedData = utils.stripBOM(convertedData);
|
260
|
+
}
|
261
|
+
} else if (responseType === 'stream') {
|
262
|
+
convertedData = stream.Readable.from(convertedData);
|
263
|
+
}
|
264
|
+
|
265
|
+
return settle(resolve, reject, {
|
266
|
+
data: convertedData,
|
267
|
+
status: 200,
|
268
|
+
statusText: 'OK',
|
269
|
+
headers: new AxiosHeaders(),
|
270
|
+
config
|
271
|
+
});
|
272
|
+
}
|
273
|
+
|
274
|
+
if (supportedProtocols.indexOf(protocol) === -1) {
|
275
|
+
return reject(new AxiosError(
|
276
|
+
'Unsupported protocol ' + protocol,
|
277
|
+
AxiosError.ERR_BAD_REQUEST,
|
278
|
+
config
|
279
|
+
));
|
280
|
+
}
|
281
|
+
|
282
|
+
const headers = AxiosHeaders.from(config.headers).normalize();
|
283
|
+
|
284
|
+
// Set User-Agent (required by some servers)
|
285
|
+
// See https://github.com/axios/axios/issues/69
|
286
|
+
// User-Agent is specified; handle case where no UA header is desired
|
287
|
+
// Only set header if it hasn't been set in config
|
288
|
+
headers.set('User-Agent', 'axios/' + VERSION, false);
|
289
|
+
|
290
|
+
const {onUploadProgress, onDownloadProgress} = config;
|
291
|
+
const maxRate = config.maxRate;
|
292
|
+
let maxUploadRate = undefined;
|
293
|
+
let maxDownloadRate = undefined;
|
294
|
+
|
295
|
+
// support for spec compliant FormData objects
|
296
|
+
if (utils.isSpecCompliantForm(data)) {
|
297
|
+
const userBoundary = headers.getContentType(/boundary=([-_\w\d]{10,70})/i);
|
298
|
+
|
299
|
+
data = formDataToStream(data, (formHeaders) => {
|
300
|
+
headers.set(formHeaders);
|
301
|
+
}, {
|
302
|
+
tag: `axios-${VERSION}-boundary`,
|
303
|
+
boundary: userBoundary && userBoundary[1] || undefined
|
304
|
+
});
|
305
|
+
// support for https://www.npmjs.com/package/form-data api
|
306
|
+
} else if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) {
|
307
|
+
headers.set(data.getHeaders());
|
308
|
+
|
309
|
+
if (!headers.hasContentLength()) {
|
310
|
+
try {
|
311
|
+
const knownLength = await util.promisify(data.getLength).call(data);
|
312
|
+
Number.isFinite(knownLength) && knownLength >= 0 && headers.setContentLength(knownLength);
|
313
|
+
/*eslint no-empty:0*/
|
314
|
+
} catch (e) {
|
315
|
+
}
|
316
|
+
}
|
317
|
+
} else if (utils.isBlob(data)) {
|
318
|
+
data.size && headers.setContentType(data.type || 'application/octet-stream');
|
319
|
+
headers.setContentLength(data.size || 0);
|
320
|
+
data = stream.Readable.from(readBlob(data));
|
321
|
+
} else if (data && !utils.isStream(data)) {
|
322
|
+
if (Buffer.isBuffer(data)) {
|
323
|
+
// Nothing to do...
|
324
|
+
} else if (utils.isArrayBuffer(data)) {
|
325
|
+
data = Buffer.from(new Uint8Array(data));
|
326
|
+
} else if (utils.isString(data)) {
|
327
|
+
data = Buffer.from(data, 'utf-8');
|
328
|
+
} else {
|
329
|
+
return reject(new AxiosError(
|
330
|
+
'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
|
331
|
+
AxiosError.ERR_BAD_REQUEST,
|
332
|
+
config
|
333
|
+
));
|
334
|
+
}
|
335
|
+
|
336
|
+
// Add Content-Length header if data exists
|
337
|
+
headers.setContentLength(data.length, false);
|
338
|
+
|
339
|
+
if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
|
340
|
+
return reject(new AxiosError(
|
341
|
+
'Request body larger than maxBodyLength limit',
|
342
|
+
AxiosError.ERR_BAD_REQUEST,
|
343
|
+
config
|
344
|
+
));
|
345
|
+
}
|
346
|
+
}
|
347
|
+
|
348
|
+
const contentLength = utils.toFiniteNumber(headers.getContentLength());
|
349
|
+
|
350
|
+
if (utils.isArray(maxRate)) {
|
351
|
+
maxUploadRate = maxRate[0];
|
352
|
+
maxDownloadRate = maxRate[1];
|
353
|
+
} else {
|
354
|
+
maxUploadRate = maxDownloadRate = maxRate;
|
355
|
+
}
|
356
|
+
|
357
|
+
if (data && (onUploadProgress || maxUploadRate)) {
|
358
|
+
if (!utils.isStream(data)) {
|
359
|
+
data = stream.Readable.from(data, {objectMode: false});
|
360
|
+
}
|
361
|
+
|
362
|
+
data = stream.pipeline([data, new AxiosTransformStream({
|
363
|
+
maxRate: utils.toFiniteNumber(maxUploadRate)
|
364
|
+
})], utils.noop);
|
365
|
+
|
366
|
+
onUploadProgress && data.on('progress', flushOnFinish(
|
367
|
+
data,
|
368
|
+
progressEventDecorator(
|
369
|
+
contentLength,
|
370
|
+
progressEventReducer(asyncDecorator(onUploadProgress), false, 3)
|
371
|
+
)
|
372
|
+
));
|
373
|
+
}
|
374
|
+
|
375
|
+
// HTTP basic authentication
|
376
|
+
let auth = undefined;
|
377
|
+
if (config.auth) {
|
378
|
+
const username = config.auth.username || '';
|
379
|
+
const password = config.auth.password || '';
|
380
|
+
auth = username + ':' + password;
|
381
|
+
}
|
382
|
+
|
383
|
+
if (!auth && parsed.username) {
|
384
|
+
const urlUsername = parsed.username;
|
385
|
+
const urlPassword = parsed.password;
|
386
|
+
auth = urlUsername + ':' + urlPassword;
|
387
|
+
}
|
388
|
+
|
389
|
+
auth && headers.delete('authorization');
|
390
|
+
|
391
|
+
let path;
|
392
|
+
|
393
|
+
try {
|
394
|
+
path = buildURL(
|
395
|
+
parsed.pathname + parsed.search,
|
396
|
+
config.params,
|
397
|
+
config.paramsSerializer
|
398
|
+
).replace(/^\?/, '');
|
399
|
+
} catch (err) {
|
400
|
+
const customErr = new Error(err.message);
|
401
|
+
customErr.config = config;
|
402
|
+
customErr.url = config.url;
|
403
|
+
customErr.exists = true;
|
404
|
+
return reject(customErr);
|
405
|
+
}
|
406
|
+
|
407
|
+
headers.set(
|
408
|
+
'Accept-Encoding',
|
409
|
+
'gzip, compress, deflate' + (isBrotliSupported ? ', br' : ''), false
|
410
|
+
);
|
411
|
+
|
412
|
+
const options = {
|
413
|
+
path,
|
414
|
+
method: method,
|
415
|
+
headers: headers.toJSON(),
|
416
|
+
agents: { http: config.httpAgent, https: config.httpsAgent },
|
417
|
+
auth,
|
418
|
+
protocol,
|
419
|
+
family,
|
420
|
+
beforeRedirect: dispatchBeforeRedirect,
|
421
|
+
beforeRedirects: {}
|
422
|
+
};
|
423
|
+
|
424
|
+
// cacheable-lookup integration hotfix
|
425
|
+
!utils.isUndefined(lookup) && (options.lookup = lookup);
|
426
|
+
|
427
|
+
if (config.socketPath) {
|
428
|
+
options.socketPath = config.socketPath;
|
429
|
+
} else {
|
430
|
+
options.hostname = parsed.hostname;
|
431
|
+
options.port = parsed.port;
|
432
|
+
setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
|
433
|
+
}
|
434
|
+
|
435
|
+
let transport;
|
436
|
+
const isHttpsRequest = isHttps.test(options.protocol);
|
437
|
+
options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
438
|
+
if (config.transport) {
|
439
|
+
transport = config.transport;
|
440
|
+
} else if (config.maxRedirects === 0) {
|
441
|
+
transport = isHttpsRequest ? https : http;
|
442
|
+
} else {
|
443
|
+
if (config.maxRedirects) {
|
444
|
+
options.maxRedirects = config.maxRedirects;
|
445
|
+
}
|
446
|
+
if (config.beforeRedirect) {
|
447
|
+
options.beforeRedirects.config = config.beforeRedirect;
|
448
|
+
}
|
449
|
+
transport = isHttpsRequest ? httpsFollow : httpFollow;
|
450
|
+
}
|
451
|
+
|
452
|
+
if (config.maxBodyLength > -1) {
|
453
|
+
options.maxBodyLength = config.maxBodyLength;
|
454
|
+
} else {
|
455
|
+
// follow-redirects does not skip comparison, so it should always succeed for axios -1 unlimited
|
456
|
+
options.maxBodyLength = Infinity;
|
457
|
+
}
|
458
|
+
|
459
|
+
if (config.insecureHTTPParser) {
|
460
|
+
options.insecureHTTPParser = config.insecureHTTPParser;
|
461
|
+
}
|
462
|
+
|
463
|
+
// Create the request
|
464
|
+
req = transport.request(options, function handleResponse(res) {
|
465
|
+
if (req.destroyed) return;
|
466
|
+
|
467
|
+
const streams = [res];
|
468
|
+
|
469
|
+
const responseLength = +res.headers['content-length'];
|
470
|
+
|
471
|
+
if (onDownloadProgress || maxDownloadRate) {
|
472
|
+
const transformStream = new AxiosTransformStream({
|
473
|
+
maxRate: utils.toFiniteNumber(maxDownloadRate)
|
474
|
+
});
|
475
|
+
|
476
|
+
onDownloadProgress && transformStream.on('progress', flushOnFinish(
|
477
|
+
transformStream,
|
478
|
+
progressEventDecorator(
|
479
|
+
responseLength,
|
480
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true, 3)
|
481
|
+
)
|
482
|
+
));
|
483
|
+
|
484
|
+
streams.push(transformStream);
|
485
|
+
}
|
486
|
+
|
487
|
+
// decompress the response body transparently if required
|
488
|
+
let responseStream = res;
|
489
|
+
|
490
|
+
// return the last request in case of redirects
|
491
|
+
const lastRequest = res.req || req;
|
492
|
+
|
493
|
+
// if decompress disabled we should not decompress
|
494
|
+
if (config.decompress !== false && res.headers['content-encoding']) {
|
495
|
+
// if no content, but headers still say that it is encoded,
|
496
|
+
// remove the header not confuse downstream operations
|
497
|
+
if (method === 'HEAD' || res.statusCode === 204) {
|
498
|
+
delete res.headers['content-encoding'];
|
499
|
+
}
|
500
|
+
|
501
|
+
switch ((res.headers['content-encoding'] || '').toLowerCase()) {
|
502
|
+
/*eslint default-case:0*/
|
503
|
+
case 'gzip':
|
504
|
+
case 'x-gzip':
|
505
|
+
case 'compress':
|
506
|
+
case 'x-compress':
|
507
|
+
// add the unzipper to the body stream processing pipeline
|
508
|
+
streams.push(zlib.createUnzip(zlibOptions));
|
509
|
+
|
510
|
+
// remove the content-encoding in order to not confuse downstream operations
|
511
|
+
delete res.headers['content-encoding'];
|
512
|
+
break;
|
513
|
+
case 'deflate':
|
514
|
+
streams.push(new ZlibHeaderTransformStream());
|
515
|
+
|
516
|
+
// add the unzipper to the body stream processing pipeline
|
517
|
+
streams.push(zlib.createUnzip(zlibOptions));
|
518
|
+
|
519
|
+
// remove the content-encoding in order to not confuse downstream operations
|
520
|
+
delete res.headers['content-encoding'];
|
521
|
+
break;
|
522
|
+
case 'br':
|
523
|
+
if (isBrotliSupported) {
|
524
|
+
streams.push(zlib.createBrotliDecompress(brotliOptions));
|
525
|
+
delete res.headers['content-encoding'];
|
526
|
+
}
|
527
|
+
}
|
528
|
+
}
|
529
|
+
|
530
|
+
responseStream = streams.length > 1 ? stream.pipeline(streams, utils.noop) : streams[0];
|
531
|
+
|
532
|
+
const offListeners = stream.finished(responseStream, () => {
|
533
|
+
offListeners();
|
534
|
+
onFinished();
|
535
|
+
});
|
536
|
+
|
537
|
+
const response = {
|
538
|
+
status: res.statusCode,
|
539
|
+
statusText: res.statusMessage,
|
540
|
+
headers: new AxiosHeaders(res.headers),
|
541
|
+
config,
|
542
|
+
request: lastRequest
|
543
|
+
};
|
544
|
+
|
545
|
+
if (responseType === 'stream') {
|
546
|
+
response.data = responseStream;
|
547
|
+
settle(resolve, reject, response);
|
548
|
+
} else {
|
549
|
+
const responseBuffer = [];
|
550
|
+
let totalResponseBytes = 0;
|
551
|
+
|
552
|
+
responseStream.on('data', function handleStreamData(chunk) {
|
553
|
+
responseBuffer.push(chunk);
|
554
|
+
totalResponseBytes += chunk.length;
|
555
|
+
|
556
|
+
// make sure the content length is not over the maxContentLength if specified
|
557
|
+
if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
|
558
|
+
// stream.destroy() emit aborted event before calling reject() on Node.js v16
|
559
|
+
rejected = true;
|
560
|
+
responseStream.destroy();
|
561
|
+
reject(new AxiosError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
|
562
|
+
AxiosError.ERR_BAD_RESPONSE, config, lastRequest));
|
563
|
+
}
|
564
|
+
});
|
565
|
+
|
566
|
+
responseStream.on('aborted', function handlerStreamAborted() {
|
567
|
+
if (rejected) {
|
568
|
+
return;
|
569
|
+
}
|
570
|
+
|
571
|
+
const err = new AxiosError(
|
572
|
+
'maxContentLength size of ' + config.maxContentLength + ' exceeded',
|
573
|
+
AxiosError.ERR_BAD_RESPONSE,
|
574
|
+
config,
|
575
|
+
lastRequest
|
576
|
+
);
|
577
|
+
responseStream.destroy(err);
|
578
|
+
reject(err);
|
579
|
+
});
|
580
|
+
|
581
|
+
responseStream.on('error', function handleStreamError(err) {
|
582
|
+
if (req.destroyed) return;
|
583
|
+
reject(AxiosError.from(err, null, config, lastRequest));
|
584
|
+
});
|
585
|
+
|
586
|
+
responseStream.on('end', function handleStreamEnd() {
|
587
|
+
try {
|
588
|
+
let responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
|
589
|
+
if (responseType !== 'arraybuffer') {
|
590
|
+
responseData = responseData.toString(responseEncoding);
|
591
|
+
if (!responseEncoding || responseEncoding === 'utf8') {
|
592
|
+
responseData = utils.stripBOM(responseData);
|
593
|
+
}
|
594
|
+
}
|
595
|
+
response.data = responseData;
|
596
|
+
} catch (err) {
|
597
|
+
return reject(AxiosError.from(err, null, config, response.request, response));
|
598
|
+
}
|
599
|
+
settle(resolve, reject, response);
|
600
|
+
});
|
601
|
+
}
|
602
|
+
|
603
|
+
emitter.once('abort', err => {
|
604
|
+
if (!responseStream.destroyed) {
|
605
|
+
responseStream.emit('error', err);
|
606
|
+
responseStream.destroy();
|
607
|
+
}
|
608
|
+
});
|
609
|
+
});
|
610
|
+
|
611
|
+
emitter.once('abort', err => {
|
612
|
+
reject(err);
|
613
|
+
req.destroy(err);
|
614
|
+
});
|
615
|
+
|
616
|
+
// Handle errors
|
617
|
+
req.on('error', function handleRequestError(err) {
|
618
|
+
// @todo remove
|
619
|
+
// if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return;
|
620
|
+
reject(AxiosError.from(err, null, config, req));
|
621
|
+
});
|
622
|
+
|
623
|
+
// set tcp keep alive to prevent drop connection by peer
|
624
|
+
req.on('socket', function handleRequestSocket(socket) {
|
625
|
+
// default interval of sending ack packet is 1 minute
|
626
|
+
socket.setKeepAlive(true, 1000 * 60);
|
627
|
+
});
|
628
|
+
|
629
|
+
// Handle request timeout
|
630
|
+
if (config.timeout) {
|
631
|
+
// This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
|
632
|
+
const timeout = parseInt(config.timeout, 10);
|
633
|
+
|
634
|
+
if (Number.isNaN(timeout)) {
|
635
|
+
reject(new AxiosError(
|
636
|
+
'error trying to parse `config.timeout` to int',
|
637
|
+
AxiosError.ERR_BAD_OPTION_VALUE,
|
638
|
+
config,
|
639
|
+
req
|
640
|
+
));
|
641
|
+
|
642
|
+
return;
|
643
|
+
}
|
644
|
+
|
645
|
+
// Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
|
646
|
+
// And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
|
647
|
+
// At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
|
648
|
+
// And then these socket which be hang up will devouring CPU little by little.
|
649
|
+
// ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
|
650
|
+
req.setTimeout(timeout, function handleRequestTimeout() {
|
651
|
+
if (isDone) return;
|
652
|
+
let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
|
653
|
+
const transitional = config.transitional || transitionalDefaults;
|
654
|
+
if (config.timeoutErrorMessage) {
|
655
|
+
timeoutErrorMessage = config.timeoutErrorMessage;
|
656
|
+
}
|
657
|
+
reject(new AxiosError(
|
658
|
+
timeoutErrorMessage,
|
659
|
+
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
660
|
+
config,
|
661
|
+
req
|
662
|
+
));
|
663
|
+
abort();
|
664
|
+
});
|
665
|
+
}
|
666
|
+
|
667
|
+
|
668
|
+
// Send the request
|
669
|
+
if (utils.isStream(data)) {
|
670
|
+
let ended = false;
|
671
|
+
let errored = false;
|
672
|
+
|
673
|
+
data.on('end', () => {
|
674
|
+
ended = true;
|
675
|
+
});
|
676
|
+
|
677
|
+
data.once('error', err => {
|
678
|
+
errored = true;
|
679
|
+
req.destroy(err);
|
680
|
+
});
|
681
|
+
|
682
|
+
data.on('close', () => {
|
683
|
+
if (!ended && !errored) {
|
684
|
+
abort(new CanceledError('Request stream has been aborted', config, req));
|
685
|
+
}
|
686
|
+
});
|
687
|
+
|
688
|
+
data.pipe(req);
|
689
|
+
} else {
|
690
|
+
req.end(data);
|
691
|
+
}
|
692
|
+
});
|
693
|
+
}
|
694
|
+
|
695
|
+
export const __setProxy = setProxy;
|