diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/CapacitorCookieManager.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/CapacitorCookieManager.java index 535e8f6b84..a78e805795 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/CapacitorCookieManager.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/CapacitorCookieManager.java @@ -17,7 +17,10 @@ public class CapacitorCookieManager extends CookieManager { private final android.webkit.CookieManager webkitCookieManager; - private final Bridge bridge; + + private final String localUrl; + + private final String serverUrl; /** * Create a new cookie manager with the default cookie store and policy @@ -36,18 +39,19 @@ public CapacitorCookieManager(Bridge bridge) { public CapacitorCookieManager(CookieStore store, CookiePolicy policy, Bridge bridge) { super(store, policy); webkitCookieManager = android.webkit.CookieManager.getInstance(); - this.bridge = bridge; + this.localUrl = bridge.getLocalUrl(); + this.serverUrl = bridge.getServerUrl(); } public String getSanitizedDomain(String url) { if (url == null || url.isEmpty()) { - url = this.bridge.getLocalUrl(); + url = this.localUrl; } try { new URI(url); } catch (Exception ex) { - return this.bridge.getServerUrl(); + return this.serverUrl; } return url; diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/CapacitorHttp.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/CapacitorHttp.java index 73201df908..9a11c2db3c 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/CapacitorHttp.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/CapacitorHttp.java @@ -31,8 +31,7 @@ private void http(final PluginCall call, final String httpMethod) { @Override public void run() { try { - HttpRequestHandler.bridge = bridge; - JSObject response = HttpRequestHandler.request(call, httpMethod); + JSObject response = HttpRequestHandler.request(call, httpMethod, getBridge()); call.resolve(response); } catch (Exception e) { call.reject(e.getLocalizedMessage(), e.getClass().getSimpleName(), e); diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/util/HttpRequestHandler.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/util/HttpRequestHandler.java index 6e8d35f1ea..b69b20334e 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/util/HttpRequestHandler.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/util/HttpRequestHandler.java @@ -27,8 +27,6 @@ public class HttpRequestHandler { - public static Bridge bridge = null; - /** * An enum specifying conventional HTTP Response Types * See https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType @@ -367,7 +365,8 @@ public static String readStreamAsString(InputStream in) throws IOException { * @throws URISyntaxException thrown when the URI is malformed * @throws JSONException thrown when the incoming JSON is malformed */ - public static JSObject request(PluginCall call, String httpMethod) throws IOException, URISyntaxException, JSONException { + public static JSObject request(PluginCall call, String httpMethod, Bridge bridge) + throws IOException, URISyntaxException, JSONException { String urlString = call.getString("url", ""); JSObject headers = call.getObject("headers"); JSObject params = call.getObject("params");