From 5ef6a3889121dd39a9159ff80250df18854bc557 Mon Sep 17 00:00:00 2001 From: Tim Lancina <804331+tlancina@users.noreply.github.com> Date: Tue, 13 Sep 2022 12:45:02 -0500 Subject: [PATCH] fix(android): set all cookies on proxied requests (#5781) --- .../main/java/com/getcapacitor/WebViewLocalServer.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java b/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java index c9def872e..097e25af4 100755 --- a/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java +++ b/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java @@ -29,6 +29,7 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -360,9 +361,12 @@ private WebResourceResponse handleProxyRequest(WebResourceRequest request, PathH String base64 = Base64.encodeToString(userInfoBytes, Base64.NO_WRAP); conn.setRequestProperty("Authorization", "Basic " + base64); } - String cookie = conn.getHeaderField("Set-Cookie"); - if (cookie != null) { - CookieManager.getInstance().setCookie(url, cookie); + + List cookies = conn.getHeaderFields().get("Set-Cookie"); + if (cookies != null) { + for (String cookie : cookies) { + CookieManager.getInstance().setCookie(url, cookie); + } } InputStream responseStream = conn.getInputStream(); responseStream = jsInjector.getInjectedStream(responseStream);