From 766a61d42fd97e686678cce9b7638cf9a0e224e7 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Tue, 9 Jun 2020 19:23:07 +0200 Subject: [PATCH] fix(android): set cookie on proxied request only if exists (#3077) --- .../src/main/java/com/getcapacitor/WebViewLocalServer.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java b/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java index 765cd9ded..319cdd2a9 100755 --- a/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java +++ b/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java @@ -297,7 +297,10 @@ private WebResourceResponse handleProxyRequest(WebResourceRequest request, PathH for (Map.Entry header : headers.entrySet()) { conn.setRequestProperty(header.getKey(), header.getValue()); } - conn.setRequestProperty("Cookie", CookieManager.getInstance().getCookie(url)); + String getCookie = CookieManager.getInstance().getCookie(url); + if (getCookie != null) { + conn.setRequestProperty("Cookie", getCookie); + } conn.setRequestMethod(method); conn.setReadTimeout(30 * 1000); conn.setConnectTimeout(30 * 1000);