-
Bug
-
Resolution: Fixed
-
P3
-
8
-
b98
-
generic
-
generic
-
Verified
If a program installs the default cookie handler, opens an HttpURLConnection to http://www.walmart.com/msharbor/, and attempts to call HttpURLConnection.getHeaderFields() on that connection, HttpURLConnection.getHeaderFields() unexpectedly throws the following exception:
Exception in thread "main" java.lang.IllegalArgumentException: Empty cookie header string
at java.net.HttpCookie.parseInternal(HttpCookie.java:828)
at java.net.HttpCookie.parse(HttpCookie.java:204)
at java.net.HttpCookie.access$100(HttpCookie.java:58)
at java.net.HttpCookie$12.parse(HttpCookie.java:979)
at sun.net.www.protocol.http.HttpURLConnection.filterHeaderField(HttpURLConnection.java:2632)
at sun.net.www.protocol.http.HttpURLConnection.getFilteredHeaderFields(HttpURLConnection.java:2669)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(HttpURLConnection.java:2713)
at emptycookieheaderstringtest.EmptyCookieHeaderStringTest.main(EmptyCookieHeaderStringTest.java:17)
To reproduce, compile and run the following program (with -DproxyHost=<proxy> -DproxyPort=<port>, if you are behind a proxy):
public class EmptyCookieHeaderStringTest {
public static void main(String[] args) throws IOException {
CookieHandler.setDefault(new TestCookieHandler());
URL url = new URL("http://www.walmart.com/msharbor/");
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) {
}
}
The problem is the root cause for https://javafx-jira.kenai.com/browse/RT-30052 .
Exception in thread "main" java.lang.IllegalArgumentException: Empty cookie header string
at java.net.HttpCookie.parseInternal(HttpCookie.java:828)
at java.net.HttpCookie.parse(HttpCookie.java:204)
at java.net.HttpCookie.access$100(HttpCookie.java:58)
at java.net.HttpCookie$12.parse(HttpCookie.java:979)
at sun.net.www.protocol.http.HttpURLConnection.filterHeaderField(HttpURLConnection.java:2632)
at sun.net.www.protocol.http.HttpURLConnection.getFilteredHeaderFields(HttpURLConnection.java:2669)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(HttpURLConnection.java:2713)
at emptycookieheaderstringtest.EmptyCookieHeaderStringTest.main(EmptyCookieHeaderStringTest.java:17)
To reproduce, compile and run the following program (with -DproxyHost=<proxy> -DproxyPort=<port>, if you are behind a proxy):
public class EmptyCookieHeaderStringTest {
public static void main(String[] args) throws IOException {
CookieHandler.setDefault(new TestCookieHandler());
URL url = new URL("http://www.walmart.com/msharbor/");
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) {
}
}
The problem is the root cause for https://javafx-jira.kenai.com/browse/RT-30052 .
- relates to
-
JDK-7183292 HttpURLConnection.getHeaderFields() throws IllegalArgumentException: Illegal cookie name
- Closed