1
1
package com .github .triniwiz .async ;
2
2
3
+ import android .os .Handler ;
4
+ import android .os .HandlerThread ;
3
5
import androidx .annotation .Nullable ;
4
-
5
6
import okhttp3 .*;
6
7
import okhttp3 .internal .http2 .ErrorCode ;
7
8
import okhttp3 .internal .http2 .StreamResetException ;
8
9
import okio .*;
9
-
10
10
import org .json .JSONArray ;
11
11
import org .json .JSONException ;
12
12
import org .json .JSONObject ;
27
27
import java .util .concurrent .Executors ;
28
28
import java .util .concurrent .TimeUnit ;
29
29
30
- import android .os .Handler ;
31
- import android .os .HandlerThread ;
32
-
33
30
/**
34
31
* Created by triniwiz on 2019-06-19
35
32
*/
@@ -335,7 +332,8 @@ public Request authenticate(Route route, Response response) throws IOException {
335
332
}
336
333
}
337
334
RequestBody body = null ;
338
- if (options .method .equals ("POST" ) || options .method .equals ("PUT" )) {
335
+ boolean isPostOrPut = options .method .equals ("POST" ) || options .method .equals ("PUT" );
336
+ if (isPostOrPut ) {
339
337
if (options .content instanceof File ) {
340
338
341
339
} else if (options .content instanceof String ) {
@@ -352,8 +350,11 @@ public void onProgress(long loaded, long total) {
352
350
callback .onProgress (total > -1 , loaded , total );
353
351
}
354
352
});
353
+ }else {
354
+ body = RequestBody .create (null ,"" );
355
355
}
356
356
}
357
+
357
358
request .method (options .method , body );
358
359
OkHttpClient client = builder .build ();
359
360
Call call = client .newCall (request .build ());
0 commit comments