Test if the host name appears to be a fully qualified DNS name, IPv4 address or IPv6 address
git-svn-id: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpclient/trunk@583886 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
19e029924f
commit
e215891dd0
|
@ -212,11 +212,22 @@ public class RFC2965Spec extends RFC2109Spec {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static CookieOrigin adjustEffectiveHost(final CookieOrigin origin) {
|
private static CookieOrigin adjustEffectiveHost(final CookieOrigin origin) {
|
||||||
String effectiveHost = origin.getHost();
|
String host = origin.getHost();
|
||||||
if (effectiveHost.indexOf('.') < 0) {
|
|
||||||
effectiveHost += ".local";
|
// Test if the host name appears to be a fully qualified DNS name,
|
||||||
|
// IPv4 address or IPv6 address
|
||||||
|
boolean isLocalHost = true;
|
||||||
|
for (int i = 0; i < host.length(); i++) {
|
||||||
|
char ch = host.charAt(i);
|
||||||
|
if (ch == '.' || ch == ':') {
|
||||||
|
isLocalHost = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isLocalHost) {
|
||||||
|
host += ".local";
|
||||||
return new CookieOrigin(
|
return new CookieOrigin(
|
||||||
effectiveHost,
|
host,
|
||||||
origin.getPort(),
|
origin.getPort(),
|
||||||
origin.getPath(),
|
origin.getPath(),
|
||||||
origin.isSecure());
|
origin.isSecure());
|
||||||
|
|
Loading…
Reference in New Issue