File tree 1 file changed +16
-7
lines changed
1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -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,10 +121,13 @@ 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
132
method : 'POST' ,
126
133
body : data ,
@@ -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 ) ) {
You can’t perform that action at this time.
0 commit comments