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)
|
||||
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) &&
|
||||
!"POST".equals(method) &&
|
||||
!"PUT".equals(method)
|
||||
|
|
|
@ -131,12 +131,12 @@ final class OSGiHttpRoutePlanner extends DefaultRoutePlanner {
|
|||
private final String domainName;
|
||||
|
||||
DomainNameMatcher(final String domainName) {
|
||||
this.domainName = domainName.toLowerCase(Locale.ENGLISH);
|
||||
this.domainName = domainName.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
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,
|
||||
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.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() {
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
if (this.scheme != null) {
|
||||
buffer.append(this.scheme.toUpperCase(Locale.ENGLISH));
|
||||
buffer.append(this.scheme.toUpperCase(Locale.ROOT));
|
||||
buffer.append(' ');
|
||||
}
|
||||
if (this.realm != null) {
|
||||
|
|
|
@ -75,7 +75,7 @@ public class NTCredentials implements Credentials, Serializable {
|
|||
final int atSlash = username.indexOf('/');
|
||||
if (atSlash >= 0) {
|
||||
this.principal = new NTUserPrincipal(
|
||||
username.substring(0, atSlash).toUpperCase(Locale.ENGLISH),
|
||||
username.substring(0, atSlash).toUpperCase(Locale.ROOT),
|
||||
username.substring(atSlash + 1));
|
||||
} else {
|
||||
this.principal = new NTUserPrincipal(
|
||||
|
@ -104,7 +104,7 @@ public class NTCredentials implements Credentials, Serializable {
|
|||
this.principal = new NTUserPrincipal(domain, userName);
|
||||
this.password = password;
|
||||
if (workstation != null) {
|
||||
this.workstation = workstation.toUpperCase(Locale.ENGLISH);
|
||||
this.workstation = workstation.toUpperCase(Locale.ROOT);
|
||||
} else {
|
||||
this.workstation = null;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class NTUserPrincipal implements Principal, Serializable {
|
|||
Args.notNull(username, "User name");
|
||||
this.username = username;
|
||||
if (domain != null) {
|
||||
this.domain = domain.toUpperCase(Locale.ENGLISH);
|
||||
this.domain = domain.toUpperCase(Locale.ROOT);
|
||||
} else {
|
||||
this.domain = null;
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ public class URIUtils {
|
|||
uribuilder.setPath("/");
|
||||
}
|
||||
if (uribuilder.getHost() != null) {
|
||||
uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ENGLISH));
|
||||
uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
uribuilder.setFragment(null);
|
||||
return uribuilder.build();
|
||||
|
|
|
@ -50,7 +50,7 @@ public final class CookieOrigin {
|
|||
Args.notBlank(host, "Host");
|
||||
Args.notNegative(port, "Port");
|
||||
Args.notNull(path, "Path");
|
||||
this.host = host.toLowerCase(Locale.ENGLISH);
|
||||
this.host = host.toLowerCase(Locale.ROOT);
|
||||
this.port = port;
|
||||
if (!path.trim().isEmpty()) {
|
||||
this.path = path;
|
||||
|
|
|
@ -137,7 +137,7 @@ public abstract class RFC2617Scheme extends AuthSchemeBase {
|
|||
if (name == 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 {
|
||||
SCHEME_MAP = new ConcurrentHashMap<String, String>();
|
||||
SCHEME_MAP.put(AuthSchemes.BASIC.toUpperCase(Locale.ENGLISH), "Basic");
|
||||
SCHEME_MAP.put(AuthSchemes.DIGEST.toUpperCase(Locale.ENGLISH), "Digest");
|
||||
SCHEME_MAP.put(AuthSchemes.NTLM.toUpperCase(Locale.ENGLISH), "NTLM");
|
||||
SCHEME_MAP.put(AuthSchemes.SPNEGO.toUpperCase(Locale.ENGLISH), "SPNEGO");
|
||||
SCHEME_MAP.put(AuthSchemes.KERBEROS.toUpperCase(Locale.ENGLISH), "Kerberos");
|
||||
SCHEME_MAP.put(AuthSchemes.BASIC.toUpperCase(Locale.ROOT), "Basic");
|
||||
SCHEME_MAP.put(AuthSchemes.DIGEST.toUpperCase(Locale.ROOT), "Digest");
|
||||
SCHEME_MAP.put(AuthSchemes.NTLM.toUpperCase(Locale.ROOT), "NTLM");
|
||||
SCHEME_MAP.put(AuthSchemes.SPNEGO.toUpperCase(Locale.ROOT), "SPNEGO");
|
||||
SCHEME_MAP.put(AuthSchemes.KERBEROS.toUpperCase(Locale.ROOT), "Kerberos");
|
||||
}
|
||||
|
||||
private static String translateScheme(final String key) {
|
||||
|
|
|
@ -196,7 +196,7 @@ public class BasicClientCookie implements SetCookie, ClientCookie, Cloneable, Se
|
|||
@Override
|
||||
public void setDomain(final String domain) {
|
||||
if (domain != null) {
|
||||
cookieDomain = domain.toLowerCase(Locale.ENGLISH);
|
||||
cookieDomain = domain.toLowerCase(Locale.ROOT);
|
||||
} else {
|
||||
cookieDomain = null;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public abstract class CookieSpecBase extends AbstractCookieSpec {
|
|||
final NameValuePair[] attribs = headerelement.getParameters();
|
||||
for (int j = attribs.length - 1; j >= 0; 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());
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ public class NetscapeDomainHandler extends BasicDomainHandler {
|
|||
* @return True if the specified domain is "special"
|
||||
*/
|
||||
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")
|
||||
|| ucDomain.endsWith(".EDU")
|
||||
|| ucDomain.endsWith(".NET")
|
||||
|
|
|
@ -92,7 +92,7 @@ public class RFC2109DomainHandler implements CookieAttributeHandler {
|
|||
+ domain
|
||||
+ "\" violates RFC 2109: domain must contain an embedded dot");
|
||||
}
|
||||
host = host.toLowerCase(Locale.ENGLISH);
|
||||
host = host.toLowerCase(Locale.ROOT);
|
||||
if (!host.endsWith(domain)) {
|
||||
throw new CookieRestrictionViolationException(
|
||||
"Illegal domain attribute \"" + domain
|
||||
|
|
|
@ -68,7 +68,7 @@ public class RFC2965DomainAttributeHandler implements CookieAttributeHandler {
|
|||
"Blank value for domain attribute");
|
||||
}
|
||||
String s = domain;
|
||||
s = s.toLowerCase(Locale.ENGLISH);
|
||||
s = s.toLowerCase(Locale.ROOT);
|
||||
if (!domain.startsWith(".")) {
|
||||
// Per RFC 2965 section 3.2.2
|
||||
// "... If an explicitly specified value does not start with
|
||||
|
@ -110,12 +110,12 @@ public class RFC2965DomainAttributeHandler implements CookieAttributeHandler {
|
|||
throws MalformedCookieException {
|
||||
Args.notNull(cookie, "Cookie");
|
||||
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) {
|
||||
throw new CookieRestrictionViolationException("Invalid cookie state: " +
|
||||
"domain not specified");
|
||||
}
|
||||
final String cookieDomain = cookie.getDomain().toLowerCase(Locale.ENGLISH);
|
||||
final String cookieDomain = cookie.getDomain().toLowerCase(Locale.ROOT);
|
||||
|
||||
if (cookie instanceof ClientCookie
|
||||
&& ((ClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR)) {
|
||||
|
@ -171,7 +171,7 @@ public class RFC2965DomainAttributeHandler implements CookieAttributeHandler {
|
|||
public boolean match(final Cookie cookie, final CookieOrigin origin) {
|
||||
Args.notNull(cookie, "Cookie");
|
||||
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();
|
||||
|
||||
// The effective host name MUST domain-match the Domain
|
||||
|
|
|
@ -116,11 +116,11 @@ public class RFC2965Spec extends RFC2109Spec {
|
|||
new HashMap<String, NameValuePair>(attribs.length);
|
||||
for (int j = attribs.length - 1; j >= 0; 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()) {
|
||||
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());
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public class EchoHandler
|
|||
final HttpContext context)
|
||||
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) &&
|
||||
!"POST".equals(method) &&
|
||||
!"PUT".equals(method)
|
||||
|
|
|
@ -68,7 +68,7 @@ public class RandomHandler implements HttpRequestHandler {
|
|||
final HttpContext context)
|
||||
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)) {
|
||||
throw new MethodNotSupportedException
|
||||
(method + " not supported by " + getClass().getName());
|
||||
|
|
Loading…
Reference in New Issue