Skip to content

Commit

Permalink
fix(android): set cookie on proxied request (#3076)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Jun 9, 2020
1 parent 171870b commit 9b96edc
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,20 @@ private WebResourceResponse handleProxyRequest(WebResourceRequest request, PathH
if (method.equals("GET")) {
try {
String path = request.getUrl().getPath();
URL url = new URL(request.getUrl().toString());
String url = request.getUrl().toString();
Map<String, String> headers = request.getRequestHeaders();
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
for (Map.Entry<String, String> header : headers.entrySet()) {
conn.setRequestProperty(header.getKey(), header.getValue());
}
conn.setRequestProperty("Cookie", CookieManager.getInstance().getCookie(request.getUrl().toString()));
conn.setRequestProperty("Cookie", CookieManager.getInstance().getCookie(url));
conn.setRequestMethod(method);
conn.setReadTimeout(30 * 1000);
conn.setConnectTimeout(30 * 1000);
String cookie = conn.getHeaderField("Set-Cookie");
if (cookie != null) {
CookieManager.getInstance().setCookie(url, cookie);
}

if (conn.getContentType().contains("text/html")) {
InputStream responseStream = conn.getInputStream();
Expand Down

0 comments on commit 9b96edc

Please sign in to comment.