6349566: java.net.CookieManager doesn't set default domain
Enforce default domain in CookieManager Reviewed-by: michaelm
This commit is contained in:
parent
2af45eb571
commit
97c0be0045
@ -286,6 +286,14 @@ public class CookieManager extends CookieHandler
|
||||
}
|
||||
cookie.setPath(path);
|
||||
}
|
||||
|
||||
// As per RFC 2965, section 3.3.1:
|
||||
// Domain Defaults to the effective request-host. (Note that because
|
||||
// there is no dot at the beginning of effective request-host,
|
||||
// the default Domain can only domain-match itself.)
|
||||
if (cookie.getDomain() == null) {
|
||||
cookie.setDomain(uri.getHost());
|
||||
}
|
||||
String ports = cookie.getPortlist();
|
||||
if (ports != null) {
|
||||
int port = uri.getPort();
|
||||
|
@ -218,21 +218,22 @@ class CookieHttpTransaction implements HttpCallback {
|
||||
};
|
||||
|
||||
// cookies without domain attributes
|
||||
// RFC 2965 states that domain should default to host
|
||||
testPolicies[count] = CookiePolicy.ACCEPT_ALL;
|
||||
testCases[count++] = new CookieTestCase[]{
|
||||
new CookieTestCase("Set-Cookie2",
|
||||
"Customer=\"WILE_E_COYOTE\"; Version=\"1\"; Path=\"/acme\"",
|
||||
"$Version=\"1\"; Customer=\"WILE_E_COYOTE\";$Path=\"/acme\"",
|
||||
"$Version=\"1\"; Customer=\"WILE_E_COYOTE\";$Path=\"/acme\";$Domain=\""+localHostAddr+"\"",
|
||||
"/acme/login"
|
||||
),
|
||||
new CookieTestCase("Set-Cookie2",
|
||||
"Part_Number=\"Rocket_Launcher_0001\"; Version=\"1\";Path=\"/acme\"",
|
||||
"$Version=\"1\"; Customer=\"WILE_E_COYOTE\";$Path=\"/acme\"" + "; Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\"",
|
||||
"$Version=\"1\"; Customer=\"WILE_E_COYOTE\";$Path=\"/acme\";$Domain=\""+localHostAddr+"\"" + "; Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\";$Domain=\""+localHostAddr+"\"",
|
||||
"/acme/pickitem"
|
||||
),
|
||||
new CookieTestCase("Set-Cookie2",
|
||||
"Shipping=\"FedEx\"; Version=\"1\"; Path=\"/acme\"",
|
||||
"$Version=\"1\"; Customer=\"WILE_E_COYOTE\";$Path=\"/acme\"" + "; Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\"" + "; Shipping=\"FedEx\";$Path=\"/acme\"",
|
||||
"$Version=\"1\"; Customer=\"WILE_E_COYOTE\";$Path=\"/acme\";$Domain=\""+localHostAddr+"\"" + "; Part_Number=\"Rocket_Launcher_0001\";$Path=\"/acme\";$Domain=\""+localHostAddr+"\"" + "; Shipping=\"FedEx\";$Path=\"/acme\";$Domain=\""+localHostAddr+"\"",
|
||||
"/acme/shipping"
|
||||
)
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user