axios 1.7.0-beta.1 → 1.7.0-beta.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.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

@@ -59,6 +59,10 @@ isFetchSupported && (((res) => {
59
59
  })(new Response));
60
60
 
61
61
  const getBodyLength = async (body) => {
62
+ if (body == null) {
63
+ return 0;
64
+ }
65
+
62
66
  if(utils.isBlob(body)) {
63
67
  return body.size;
64
68
  }
@@ -117,12 +121,15 @@ export default isFetchSupported && (async (config) => {
117
121
  finished = true;
118
122
  }
119
123
 
120
- try {
121
- if (onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head') {
122
- let requestContentLength = await resolveBodyLength(headers, data);
124
+ let requestContentLength;
123
125
 
126
+ try {
127
+ if (
128
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
129
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
130
+ ) {
124
131
  let _request = new Request(url, {
125
- method,
132
+ method: 'POST',
126
133
  body: data,
127
134
  duplex: "half"
128
135
  });
@@ -133,10 +140,12 @@ export default isFetchSupported && (async (config) => {
133
140
  headers.setContentType(contentTypeHeader)
134
141
  }
135
142
 
136
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
137
- requestContentLength,
138
- progressEventReducer(onUploadProgress)
139
- ));
143
+ if (_request.body) {
144
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
145
+ requestContentLength,
146
+ progressEventReducer(onUploadProgress)
147
+ ));
148
+ }
140
149
  }
141
150
 
142
151
  if (!utils.isString(withCredentials)) {
@@ -146,7 +155,7 @@ export default isFetchSupported && (async (config) => {
146
155
  request = new Request(url, {
147
156
  ...fetchOptions,
148
157
  signal: composedSignal,
149
- method,
158
+ method: method.toUpperCase(),
150
159
  headers: headers.normalize().toJSON(),
151
160
  body: data,
152
161
  duplex: "half",
@@ -160,7 +169,7 @@ export default isFetchSupported && (async (config) => {
160
169
  if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
161
170
  const options = {};
162
171
 
163
- Object.getOwnPropertyNames(response).forEach(prop => {
172
+ ['status', 'statusText', 'headers'].forEach(prop => {
164
173
  options[prop] = response[prop];
165
174
  });
166
175
 
package/lib/env/data.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.7.0-beta.1";
1
+ export const VERSION = "1.7.0-beta.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axios",
3
- "version": "1.7.0-beta.1",
3
+ "version": "1.7.0-beta.2",
4
4
  "description": "Promise based HTTP client for the browser and node.js",
5
5
  "main": "index.js",
6
6
  "exports": {