From 842f365194d3861c71aa3494a1ba6b521391b0e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Manuel=20Carrasco=20Mo=C3=B1ino?= Date: Wed, 22 Jan 2014 07:09:01 +0000 Subject: [PATCH] Support passing full url to cookie manager --- .../java/com/google/gwt/query/vm/CookieManager.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/CookieManager.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/CookieManager.java index e33620b6..1f1241ba 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/CookieManager.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/CookieManager.java @@ -3,7 +3,6 @@ package com.google.gwt.query.vm; import java.io.IOException; import java.net.URL; import java.net.URLConnection; -import java.net.URLEncoder; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -39,6 +38,10 @@ public class CookieManager { return cookieManager; } + public void clear() { + store.clear(); + } + public void removeDomainCookies(String domain) { store.remove(domain); } @@ -52,7 +55,11 @@ public class CookieManager { } } - public void setDomcainCookieProp(String host, String name, String prop, String value) { + public void setDomcainCookie(String host, String name, String value) { + setDomcainCookieProperty(host, name, name, value); + } + + public void setDomcainCookieProperty(String host, String name, String prop, String value) { String domain = getDomainFromHost(host); Map> domainStore = store.get(domain); if (domainStore == null) { @@ -169,7 +176,6 @@ public class CookieManager { } try { conn.setRequestProperty(COOKIE, cookieStringBuffer.toString()); - System.err.println(">>> SET cookie: " + COOKIE + " " + cookieStringBuffer.toString()); } catch (java.lang.IllegalStateException ise) { IOException ioe = new IOException( @@ -180,6 +186,7 @@ public class CookieManager { } private String getDomainFromHost(String host) { + host = host.toLowerCase().replaceFirst("https?://", "").replaceAll("[/?:].*$", ""); if (host.indexOf(DOT) != host.lastIndexOf(DOT)) { return host.substring(host.indexOf(DOT) + 1); } else { -- 2.39.5