Use Locale.ROOT instead of Locale.US or Locale.ENGLISH for upper/lower case conversion of locale independent textual identifiers
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1567923 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7ec8359476
commit
60f0724533
|
@ -260,7 +260,7 @@ public class TestStaleWhileRevalidationReleasesConnection {
|
||||||
final HttpContext context)
|
final HttpContext context)
|
||||||
throws HttpException, IOException {
|
throws HttpException, IOException {
|
||||||
|
|
||||||
final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH);
|
final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ROOT);
|
||||||
if (!"GET".equals(method) &&
|
if (!"GET".equals(method) &&
|
||||||
!"POST".equals(method) &&
|
!"POST".equals(method) &&
|
||||||
!"PUT".equals(method)
|
!"PUT".equals(method)
|
||||||
|
|
|
@ -131,12 +131,12 @@ final class OSGiHttpRoutePlanner extends DefaultRoutePlanner {
|
||||||
private final String domainName;
|
private final String domainName;
|
||||||
|
|
||||||
DomainNameMatcher(final String domainName) {
|
DomainNameMatcher(final String domainName) {
|
||||||
this.domainName = domainName.toLowerCase(Locale.ENGLISH);
|
this.domainName = domainName.toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(final String host) {
|
public boolean matches(final String host) {
|
||||||
return host.toLowerCase(Locale.ENGLISH).endsWith(domainName);
|
return host.toLowerCase(Locale.ROOT).endsWith(domainName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,10 +104,10 @@ public class AuthScope {
|
||||||
public AuthScope(final String host, final int port,
|
public AuthScope(final String host, final int port,
|
||||||
final String realm, final String scheme)
|
final String realm, final String scheme)
|
||||||
{
|
{
|
||||||
this.host = (host == null) ? ANY_HOST: host.toLowerCase(Locale.ENGLISH);
|
this.host = (host == null) ? ANY_HOST: host.toLowerCase(Locale.ROOT);
|
||||||
this.port = (port < 0) ? ANY_PORT: port;
|
this.port = (port < 0) ? ANY_PORT: port;
|
||||||
this.realm = (realm == null) ? ANY_REALM: realm;
|
this.realm = (realm == null) ? ANY_REALM: realm;
|
||||||
this.scheme = (scheme == null) ? ANY_SCHEME: scheme.toUpperCase(Locale.ENGLISH);
|
this.scheme = (scheme == null) ? ANY_SCHEME: scheme.toUpperCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -266,7 +266,7 @@ public class AuthScope {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuilder buffer = new StringBuilder();
|
final StringBuilder buffer = new StringBuilder();
|
||||||
if (this.scheme != null) {
|
if (this.scheme != null) {
|
||||||
buffer.append(this.scheme.toUpperCase(Locale.ENGLISH));
|
buffer.append(this.scheme.toUpperCase(Locale.ROOT));
|
||||||
buffer.append(' ');
|
buffer.append(' ');
|
||||||
}
|
}
|
||||||
if (this.realm != null) {
|
if (this.realm != null) {
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class NTCredentials implements Credentials, Serializable {
|
||||||
final int atSlash = username.indexOf('/');
|
final int atSlash = username.indexOf('/');
|
||||||
if (atSlash >= 0) {
|
if (atSlash >= 0) {
|
||||||
this.principal = new NTUserPrincipal(
|
this.principal = new NTUserPrincipal(
|
||||||
username.substring(0, atSlash).toUpperCase(Locale.ENGLISH),
|
username.substring(0, atSlash).toUpperCase(Locale.ROOT),
|
||||||
username.substring(atSlash + 1));
|
username.substring(atSlash + 1));
|
||||||
} else {
|
} else {
|
||||||
this.principal = new NTUserPrincipal(
|
this.principal = new NTUserPrincipal(
|
||||||
|
@ -104,7 +104,7 @@ public class NTCredentials implements Credentials, Serializable {
|
||||||
this.principal = new NTUserPrincipal(domain, userName);
|
this.principal = new NTUserPrincipal(domain, userName);
|
||||||
this.password = password;
|
this.password = password;
|
||||||
if (workstation != null) {
|
if (workstation != null) {
|
||||||
this.workstation = workstation.toUpperCase(Locale.ENGLISH);
|
this.workstation = workstation.toUpperCase(Locale.ROOT);
|
||||||
} else {
|
} else {
|
||||||
this.workstation = null;
|
this.workstation = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class NTUserPrincipal implements Principal, Serializable {
|
||||||
Args.notNull(username, "User name");
|
Args.notNull(username, "User name");
|
||||||
this.username = username;
|
this.username = username;
|
||||||
if (domain != null) {
|
if (domain != null) {
|
||||||
this.domain = domain.toUpperCase(Locale.ENGLISH);
|
this.domain = domain.toUpperCase(Locale.ROOT);
|
||||||
} else {
|
} else {
|
||||||
this.domain = null;
|
this.domain = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ public class URIUtils {
|
||||||
uribuilder.setPath("/");
|
uribuilder.setPath("/");
|
||||||
}
|
}
|
||||||
if (uribuilder.getHost() != null) {
|
if (uribuilder.getHost() != null) {
|
||||||
uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ENGLISH));
|
uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
uribuilder.setFragment(null);
|
uribuilder.setFragment(null);
|
||||||
return uribuilder.build();
|
return uribuilder.build();
|
||||||
|
|
|
@ -50,7 +50,7 @@ public final class CookieOrigin {
|
||||||
Args.notBlank(host, "Host");
|
Args.notBlank(host, "Host");
|
||||||
Args.notNegative(port, "Port");
|
Args.notNegative(port, "Port");
|
||||||
Args.notNull(path, "Path");
|
Args.notNull(path, "Path");
|
||||||
this.host = host.toLowerCase(Locale.ENGLISH);
|
this.host = host.toLowerCase(Locale.ROOT);
|
||||||
this.port = port;
|
this.port = port;
|
||||||
if (!path.trim().isEmpty()) {
|
if (!path.trim().isEmpty()) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
|
|
|
@ -137,7 +137,7 @@ public abstract class RFC2617Scheme extends AuthSchemeBase {
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this.params.get(name.toLowerCase(Locale.ENGLISH));
|
return this.params.get(name.toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,11 +54,11 @@ public class SystemDefaultCredentialsProvider implements CredentialsProvider {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SCHEME_MAP = new ConcurrentHashMap<String, String>();
|
SCHEME_MAP = new ConcurrentHashMap<String, String>();
|
||||||
SCHEME_MAP.put(AuthSchemes.BASIC.toUpperCase(Locale.ENGLISH), "Basic");
|
SCHEME_MAP.put(AuthSchemes.BASIC.toUpperCase(Locale.ROOT), "Basic");
|
||||||
SCHEME_MAP.put(AuthSchemes.DIGEST.toUpperCase(Locale.ENGLISH), "Digest");
|
SCHEME_MAP.put(AuthSchemes.DIGEST.toUpperCase(Locale.ROOT), "Digest");
|
||||||
SCHEME_MAP.put(AuthSchemes.NTLM.toUpperCase(Locale.ENGLISH), "NTLM");
|
SCHEME_MAP.put(AuthSchemes.NTLM.toUpperCase(Locale.ROOT), "NTLM");
|
||||||
SCHEME_MAP.put(AuthSchemes.SPNEGO.toUpperCase(Locale.ENGLISH), "SPNEGO");
|
SCHEME_MAP.put(AuthSchemes.SPNEGO.toUpperCase(Locale.ROOT), "SPNEGO");
|
||||||
SCHEME_MAP.put(AuthSchemes.KERBEROS.toUpperCase(Locale.ENGLISH), "Kerberos");
|
SCHEME_MAP.put(AuthSchemes.KERBEROS.toUpperCase(Locale.ROOT), "Kerberos");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String translateScheme(final String key) {
|
private static String translateScheme(final String key) {
|
||||||
|
|
|
@ -196,7 +196,7 @@ public class BasicClientCookie implements SetCookie, ClientCookie, Cloneable, Se
|
||||||
@Override
|
@Override
|
||||||
public void setDomain(final String domain) {
|
public void setDomain(final String domain) {
|
||||||
if (domain != null) {
|
if (domain != null) {
|
||||||
cookieDomain = domain.toLowerCase(Locale.ENGLISH);
|
cookieDomain = domain.toLowerCase(Locale.ROOT);
|
||||||
} else {
|
} else {
|
||||||
cookieDomain = null;
|
cookieDomain = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ public abstract class CookieSpecBase extends AbstractCookieSpec {
|
||||||
final NameValuePair[] attribs = headerelement.getParameters();
|
final NameValuePair[] attribs = headerelement.getParameters();
|
||||||
for (int j = attribs.length - 1; j >= 0; j--) {
|
for (int j = attribs.length - 1; j >= 0; j--) {
|
||||||
final NameValuePair attrib = attribs[j];
|
final NameValuePair attrib = attribs[j];
|
||||||
final String s = attrib.getName().toLowerCase(Locale.ENGLISH);
|
final String s = attrib.getName().toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
cookie.setAttribute(s, attrib.getValue());
|
cookie.setAttribute(s, attrib.getValue());
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class NetscapeDomainHandler extends BasicDomainHandler {
|
||||||
* @return True if the specified domain is "special"
|
* @return True if the specified domain is "special"
|
||||||
*/
|
*/
|
||||||
private static boolean isSpecialDomain(final String domain) {
|
private static boolean isSpecialDomain(final String domain) {
|
||||||
final String ucDomain = domain.toUpperCase(Locale.ENGLISH);
|
final String ucDomain = domain.toUpperCase(Locale.ROOT);
|
||||||
return ucDomain.endsWith(".COM")
|
return ucDomain.endsWith(".COM")
|
||||||
|| ucDomain.endsWith(".EDU")
|
|| ucDomain.endsWith(".EDU")
|
||||||
|| ucDomain.endsWith(".NET")
|
|| ucDomain.endsWith(".NET")
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class RFC2109DomainHandler implements CookieAttributeHandler {
|
||||||
+ domain
|
+ domain
|
||||||
+ "\" violates RFC 2109: domain must contain an embedded dot");
|
+ "\" violates RFC 2109: domain must contain an embedded dot");
|
||||||
}
|
}
|
||||||
host = host.toLowerCase(Locale.ENGLISH);
|
host = host.toLowerCase(Locale.ROOT);
|
||||||
if (!host.endsWith(domain)) {
|
if (!host.endsWith(domain)) {
|
||||||
throw new CookieRestrictionViolationException(
|
throw new CookieRestrictionViolationException(
|
||||||
"Illegal domain attribute \"" + domain
|
"Illegal domain attribute \"" + domain
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class RFC2965DomainAttributeHandler implements CookieAttributeHandler {
|
||||||
"Blank value for domain attribute");
|
"Blank value for domain attribute");
|
||||||
}
|
}
|
||||||
String s = domain;
|
String s = domain;
|
||||||
s = s.toLowerCase(Locale.ENGLISH);
|
s = s.toLowerCase(Locale.ROOT);
|
||||||
if (!domain.startsWith(".")) {
|
if (!domain.startsWith(".")) {
|
||||||
// Per RFC 2965 section 3.2.2
|
// Per RFC 2965 section 3.2.2
|
||||||
// "... If an explicitly specified value does not start with
|
// "... If an explicitly specified value does not start with
|
||||||
|
@ -110,12 +110,12 @@ public class RFC2965DomainAttributeHandler implements CookieAttributeHandler {
|
||||||
throws MalformedCookieException {
|
throws MalformedCookieException {
|
||||||
Args.notNull(cookie, "Cookie");
|
Args.notNull(cookie, "Cookie");
|
||||||
Args.notNull(origin, "Cookie origin");
|
Args.notNull(origin, "Cookie origin");
|
||||||
final String host = origin.getHost().toLowerCase(Locale.ENGLISH);
|
final String host = origin.getHost().toLowerCase(Locale.ROOT);
|
||||||
if (cookie.getDomain() == null) {
|
if (cookie.getDomain() == null) {
|
||||||
throw new CookieRestrictionViolationException("Invalid cookie state: " +
|
throw new CookieRestrictionViolationException("Invalid cookie state: " +
|
||||||
"domain not specified");
|
"domain not specified");
|
||||||
}
|
}
|
||||||
final String cookieDomain = cookie.getDomain().toLowerCase(Locale.ENGLISH);
|
final String cookieDomain = cookie.getDomain().toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
if (cookie instanceof ClientCookie
|
if (cookie instanceof ClientCookie
|
||||||
&& ((ClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR)) {
|
&& ((ClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR)) {
|
||||||
|
@ -171,7 +171,7 @@ public class RFC2965DomainAttributeHandler implements CookieAttributeHandler {
|
||||||
public boolean match(final Cookie cookie, final CookieOrigin origin) {
|
public boolean match(final Cookie cookie, final CookieOrigin origin) {
|
||||||
Args.notNull(cookie, "Cookie");
|
Args.notNull(cookie, "Cookie");
|
||||||
Args.notNull(origin, "Cookie origin");
|
Args.notNull(origin, "Cookie origin");
|
||||||
final String host = origin.getHost().toLowerCase(Locale.ENGLISH);
|
final String host = origin.getHost().toLowerCase(Locale.ROOT);
|
||||||
final String cookieDomain = cookie.getDomain();
|
final String cookieDomain = cookie.getDomain();
|
||||||
|
|
||||||
// The effective host name MUST domain-match the Domain
|
// The effective host name MUST domain-match the Domain
|
||||||
|
|
|
@ -116,11 +116,11 @@ public class RFC2965Spec extends RFC2109Spec {
|
||||||
new HashMap<String, NameValuePair>(attribs.length);
|
new HashMap<String, NameValuePair>(attribs.length);
|
||||||
for (int j = attribs.length - 1; j >= 0; j--) {
|
for (int j = attribs.length - 1; j >= 0; j--) {
|
||||||
final NameValuePair param = attribs[j];
|
final NameValuePair param = attribs[j];
|
||||||
attribmap.put(param.getName().toLowerCase(Locale.ENGLISH), param);
|
attribmap.put(param.getName().toLowerCase(Locale.ROOT), param);
|
||||||
}
|
}
|
||||||
for (final Map.Entry<String, NameValuePair> entry : attribmap.entrySet()) {
|
for (final Map.Entry<String, NameValuePair> entry : attribmap.entrySet()) {
|
||||||
final NameValuePair attrib = entry.getValue();
|
final NameValuePair attrib = entry.getValue();
|
||||||
final String s = attrib.getName().toLowerCase(Locale.ENGLISH);
|
final String s = attrib.getName().toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
cookie.setAttribute(s, attrib.getValue());
|
cookie.setAttribute(s, attrib.getValue());
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class EchoHandler
|
||||||
final HttpContext context)
|
final HttpContext context)
|
||||||
throws HttpException, IOException {
|
throws HttpException, IOException {
|
||||||
|
|
||||||
final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH);
|
final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ROOT);
|
||||||
if (!"GET".equals(method) &&
|
if (!"GET".equals(method) &&
|
||||||
!"POST".equals(method) &&
|
!"POST".equals(method) &&
|
||||||
!"PUT".equals(method)
|
!"PUT".equals(method)
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class RandomHandler implements HttpRequestHandler {
|
||||||
final HttpContext context)
|
final HttpContext context)
|
||||||
throws HttpException, IOException {
|
throws HttpException, IOException {
|
||||||
|
|
||||||
final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH);
|
final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ROOT);
|
||||||
if (!"GET".equals(method) && !"HEAD".equals(method)) {
|
if (!"GET".equals(method) && !"HEAD".equals(method)) {
|
||||||
throw new MethodNotSupportedException
|
throw new MethodNotSupportedException
|
||||||
(method + " not supported by " + getClass().getName());
|
(method + " not supported by " + getClass().getName());
|
||||||
|
|
Loading…
Reference in New Issue