Skip to content

Commit e8cc741

Browse files
committed
fix(android): null post body
1 parent 0d07e49 commit e8cc741

File tree

1 file changed

+7
-6
lines changed
  • src/platforms/android/java/com/github/triniwiz/async

1 file changed

+7
-6
lines changed

src/platforms/android/java/com/github/triniwiz/async/Async.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.github.triniwiz.async;
22

3+
import android.os.Handler;
4+
import android.os.HandlerThread;
35
import androidx.annotation.Nullable;
4-
56
import okhttp3.*;
67
import okhttp3.internal.http2.ErrorCode;
78
import okhttp3.internal.http2.StreamResetException;
89
import okio.*;
9-
1010
import org.json.JSONArray;
1111
import org.json.JSONException;
1212
import org.json.JSONObject;
@@ -27,9 +27,6 @@
2727
import java.util.concurrent.Executors;
2828
import java.util.concurrent.TimeUnit;
2929

30-
import android.os.Handler;
31-
import android.os.HandlerThread;
32-
3330
/**
3431
* Created by triniwiz on 2019-06-19
3532
*/
@@ -335,7 +332,8 @@ public Request authenticate(Route route, Response response) throws IOException {
335332
}
336333
}
337334
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) {
339337
if (options.content instanceof File) {
340338

341339
} else if (options.content instanceof String) {
@@ -352,8 +350,11 @@ public void onProgress(long loaded, long total) {
352350
callback.onProgress(total > -1, loaded, total);
353351
}
354352
});
353+
}else {
354+
body = RequestBody.create(null,"");
355355
}
356356
}
357+
357358
request.method(options.method, body);
358359
OkHttpClient client = builder.build();
359360
Call call = client.newCall(request.build());

0 commit comments

Comments
 (0)