axios 1.7.0-beta.2 → 1.7.1
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.
Potentially problematic release.
This version of axios might be problematic. Click here for more details.
- package/CHANGELOG.md +865 -837
- package/README.md +30 -1
- package/dist/axios.js +95 -69
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +16 -12
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +16 -12
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +1 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +16 -12
- package/dist/node/axios.cjs.map +1 -1
- package/lib/adapters/fetch.js +10 -4
- package/lib/env/data.js +1 -1
- package/lib/helpers/trackStream.js +5 -6
- package/package.json +1 -1
package/lib/adapters/fetch.js
CHANGED
@@ -20,6 +20,12 @@ const fetchProgressDecorator = (total, fn) => {
|
|
20
20
|
const isFetchSupported = typeof fetch !== 'undefined';
|
21
21
|
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
|
22
22
|
|
23
|
+
// used only inside the fetch adapter
|
24
|
+
const encodeText = isFetchSupported && (typeof TextEncoder !== 'undefined' ?
|
25
|
+
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
26
|
+
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
27
|
+
);
|
28
|
+
|
23
29
|
const supportsRequestStream = isReadableStreamSupported && (() => {
|
24
30
|
let duplexAccessed = false;
|
25
31
|
|
@@ -80,7 +86,7 @@ const getBodyLength = async (body) => {
|
|
80
86
|
}
|
81
87
|
|
82
88
|
if(utils.isString(body)) {
|
83
|
-
return (await
|
89
|
+
return (await encodeText(body)).byteLength;
|
84
90
|
}
|
85
91
|
}
|
86
92
|
|
@@ -144,7 +150,7 @@ export default isFetchSupported && (async (config) => {
|
|
144
150
|
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
|
145
151
|
requestContentLength,
|
146
152
|
progressEventReducer(onUploadProgress)
|
147
|
-
));
|
153
|
+
), null, encodeText);
|
148
154
|
}
|
149
155
|
}
|
150
156
|
|
@@ -164,7 +170,7 @@ export default isFetchSupported && (async (config) => {
|
|
164
170
|
|
165
171
|
let response = await fetch(request);
|
166
172
|
|
167
|
-
const isStreamResponse = responseType === 'stream' || responseType === 'response';
|
173
|
+
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
168
174
|
|
169
175
|
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
170
176
|
const options = {};
|
@@ -179,7 +185,7 @@ export default isFetchSupported && (async (config) => {
|
|
179
185
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(
|
180
186
|
responseContentLength,
|
181
187
|
progressEventReducer(onDownloadProgress, true)
|
182
|
-
), isStreamResponse && onFinish),
|
188
|
+
), isStreamResponse && onFinish, encodeText),
|
183
189
|
options
|
184
190
|
);
|
185
191
|
}
|
package/lib/env/data.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const VERSION = "1.7.
|
1
|
+
export const VERSION = "1.7.1";
|
@@ -1,4 +1,5 @@
|
|
1
1
|
|
2
|
+
|
2
3
|
export const streamChunk = function* (chunk, chunkSize) {
|
3
4
|
let len = chunk.byteLength;
|
4
5
|
|
@@ -17,16 +18,14 @@ export const streamChunk = function* (chunk, chunkSize) {
|
|
17
18
|
}
|
18
19
|
}
|
19
20
|
|
20
|
-
const
|
21
|
-
|
22
|
-
export const readBytes = async function* (iterable, chunkSize) {
|
21
|
+
export const readBytes = async function* (iterable, chunkSize, encode) {
|
23
22
|
for await (const chunk of iterable) {
|
24
|
-
yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await
|
23
|
+
yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
|
25
24
|
}
|
26
25
|
}
|
27
26
|
|
28
|
-
export const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
29
|
-
const iterator = readBytes(stream, chunkSize);
|
27
|
+
export const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
|
28
|
+
const iterator = readBytes(stream, chunkSize, encode);
|
30
29
|
|
31
30
|
let bytes = 0;
|
32
31
|
|