-
Bug
-
Resolution: Fixed
-
P2
-
7u4
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2227037 | 8 | Michael McMahon | P3 | Closed | Fixed | b49 |
If a program installs the default cookie handler, opens an HttpURLConnection to http://www.google.com, and attempts to call HttpURLConnection.getHeaderFields() on that connection, HttpURLConnection.getHeaderFields() unexpectedly throws the following exception:
Exception in thread "main" java.lang.IllegalArgumentException: Illegal cookie name
at java.net.HttpCookie.<init>(HttpCookie.java:158)
at java.net.HttpCookie.parseInternal(HttpCookie.java:964)
at java.net.HttpCookie.parse(HttpCookie.java:215)
at java.net.HttpCookie.access$100(HttpCookie.java:58)
at java.net.HttpCookie$12.parse(HttpCookie.java:1096)
at sun.net.www.protocol.http.HttpURLConnection.filterHeaderField(HttpURLConnection.java:2605)
at sun.net.www.protocol.http.HttpURLConnection.getFilteredHeaderFields(HttpURLConnection.java:2642)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(HttpURLConnection.java:2686)
at illegalcookienametest.IllegalCookieNameTest.main(IllegalCookieNameTest.java:17)
To reproduce, compile and run the following program (with -DproxyHost=<proxy> -DproxyPort=<port>, if you are behind a proxy):
public class IllegalCookieNameTest {
public static void main(String[] args) throws IOException {
CookieHandler.setDefault(new TestCookieHandler());
URL url = new URL("http://www.google.com/");
HttpURLConnection c = (HttpURLConnection) url.openConnection();
c.getHeaderFields();
}
}
class TestCookieHandler extends CookieHandler {
@Override
public Map<String, List<String>> get(URI uri, Map<String, List<String>> requestHeaders) {
return new HashMap<String, List<String>>();
}
@Override
public void put(URI uri, Map<String, List<String>> responseHeaders) {
}
}
This is a major problem for JavaFX WebView, see http://javafx-jira.kenai.com/browse/RT-23353
Exception in thread "main" java.lang.IllegalArgumentException: Illegal cookie name
at java.net.HttpCookie.<init>(HttpCookie.java:158)
at java.net.HttpCookie.parseInternal(HttpCookie.java:964)
at java.net.HttpCookie.parse(HttpCookie.java:215)
at java.net.HttpCookie.access$100(HttpCookie.java:58)
at java.net.HttpCookie$12.parse(HttpCookie.java:1096)
at sun.net.www.protocol.http.HttpURLConnection.filterHeaderField(HttpURLConnection.java:2605)
at sun.net.www.protocol.http.HttpURLConnection.getFilteredHeaderFields(HttpURLConnection.java:2642)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(HttpURLConnection.java:2686)
at illegalcookienametest.IllegalCookieNameTest.main(IllegalCookieNameTest.java:17)
To reproduce, compile and run the following program (with -DproxyHost=<proxy> -DproxyPort=<port>, if you are behind a proxy):
public class IllegalCookieNameTest {
public static void main(String[] args) throws IOException {
CookieHandler.setDefault(new TestCookieHandler());
URL url = new URL("http://www.google.com/");
HttpURLConnection c = (HttpURLConnection) url.openConnection();
c.getHeaderFields();
}
}
class TestCookieHandler extends CookieHandler {
@Override
public Map<String, List<String>> get(URI uri, Map<String, List<String>> requestHeaders) {
return new HashMap<String, List<String>>();
}
@Override
public void put(URI uri, Map<String, List<String>> responseHeaders) {
}
}
This is a major problem for JavaFX WebView, see http://javafx-jira.kenai.com/browse/RT-23353
- backported by
-
JDK-2227037 HttpURLConnection.getHeaderFields() throws IllegalArgumentException: Illegal cookie name
-
- Closed
-
- relates to
-
JDK-8015799 HttpURLConnection.getHeaderFields() throws IllegalArgumentException: Empty cookie header string
-
- Closed
-