From 0c42dba80dc3f2d08b06df0a7da36c927703c43b Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Wed, 19 Feb 2020 17:56:12 +0800 Subject: [PATCH] android:Okhttp's method must be uppercased --- .../doric/src/main/java/pub/doric/plugin/NetworkPlugin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doric-android/doric/src/main/java/pub/doric/plugin/NetworkPlugin.java b/doric-android/doric/src/main/java/pub/doric/plugin/NetworkPlugin.java index a5abe8c8..9a4fb48f 100644 --- a/doric-android/doric/src/main/java/pub/doric/plugin/NetworkPlugin.java +++ b/doric-android/doric/src/main/java/pub/doric/plugin/NetworkPlugin.java @@ -62,7 +62,7 @@ public class NetworkPlugin extends DoricJavaPlugin { public void request(JSObject requestVal, final DoricPromise promise) { try { String url = requestVal.getProperty("url").asString().value(); - String method = requestVal.getProperty("method").asString().value(); + String method = requestVal.getProperty("method").asString().value().toUpperCase(); JSValue headerVal = requestVal.getProperty("headers"); JSValue dataVal = requestVal.getProperty("data"); JSValue timeoutVal = requestVal.getProperty("timeout"); @@ -81,7 +81,7 @@ public class NetworkPlugin extends DoricJavaPlugin { RequestBody requestBody = HttpMethod.permitsRequestBody(method) ? RequestBody.create(mediaType, dataVal.isString() ? dataVal.asString().value() : "") : null; Request.Builder requestBuilder = new Request.Builder(); requestBuilder = requestBuilder.url(url).headers(headers); - if (HttpMethod.permitsRequestBody(method.toUpperCase())) { + if (HttpMethod.permitsRequestBody(method)) { requestBuilder = requestBuilder.method(method, requestBody); } if (timeoutVal.isNumber() && okHttpClient.connectTimeoutMillis() != timeoutVal.asNumber().toLong()) {