Did some checking and the TC 4.0 HTTP/1.1 and HTTP/1.0 connectors have
the same problem (o.a.c.c.http and o.a.c.c.http10).
I've modified the connectors in question and ran the same set of tests
that I ran against Coyote and all seems well. Locales with variants are
properly handled.
I've attached patches for all 3 connectors.
-rl
-Forwarded Message-
From: Ryan Lubke [EMAIL PROTECTED]
To: tcdev [EMAIL PROTECTED]
Subject: [PATCH] TC 4.0/Coyote locale parsing issue
Date: 25 Mar 2002 13:35:28 -0500
Hi,
When dealing with preferred locales from a client (Accept-Language),
the CoyoteRequest class (org.apache.coyote.tomcat4) doesn't correctly
handle locales with variants (i.e. en-IE-EURO).
RFC 2616 states that the following for language-range of
Accept-Language:
language-range = ( ( 1*8ALPHA *( - 1*8ALPHA ) ) | * )
So it seems that variants coming in from a client are legal (provided
I've read the BNF properly)
The attached patch seems to correct the issue.
-rl
Index: CoyoteRequest.java
===
RCS file:
/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteRequest.java,v
retrieving revision 1.11
diff -u -r1.11 CoyoteRequest.java
--- CoyoteRequest.java 19 Mar 2002 20:34:41 - 1.11
+++ CoyoteRequest.java 25 Mar 2002 14:34:54 -
@@ -1987,17 +1987,27 @@
// Extract the language and country for this entry
String language = null;
String country = null;
+String variant = null;
int dash = entry.indexOf('-');
if (dash 0) {
language = entry;
country = ;
+variant = ;
} else {
language = entry.substring(0, dash);
country = entry.substring(dash + 1);
+int vDash = country.indexOf('-');
+if (vDash 0) {
+String cTemp = country.substring(0, vDash);
+variant = country.substring(vDash + 1);
+country = cTemp;
+} else {
+variant = ;
+}
}
// Add a new Locale to the list of Locales for this quality level
-Locale locale = new Locale(language, country);
+Locale locale = new Locale(language, country, variant);
Double key = new Double(-quality); // Reverse the order
ArrayList values = (ArrayList) locales.get(key);
if (values == null) {
--
To unsubscribe, e-mail: mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Index: HttpProcessor.java
===
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http10/HttpProcessor.java,v
retrieving revision 1.8
diff -u -r1.8 HttpProcessor.java
--- HttpProcessor.java 18 Mar 2002 07:15:40 - 1.8
+++ HttpProcessor.java 27 Mar 2002 15:17:59 -
@@ -463,12 +463,19 @@
while (le.hasMoreElements()) {
String language = (String)le.nextElement();
String country = ;
+String variant = ;
int countryIndex = language.indexOf('-');
if (countryIndex -1) {
country = language.substring(countryIndex + 1).trim();
language = language.substring(0, countryIndex).trim();
+int vDash = country.indexOf(-);
+if (vDash 0) {
+String cTemp = country.substring(0, vDash);
+variant = country.substring(vDash + 1);
+country = cTemp;
+}
}
-request.addLocale(new Locale(language, country));
+request.addLocale(new Locale(language, country, variant));
}
}
} else if (match.equals(cookie)) {
Index: HttpProcessor.java
===
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java,v
retrieving revision 1.45
diff -u -r1.45 HttpProcessor.java
--- HttpProcessor.java 18 Mar 2002 07:15:40 - 1.45
+++ HttpProcessor.java 27 Mar 2002 15:17:39 -
@@ -499,17 +499,27 @@
// Extract the language and country for this entry
String language = null;
String country = null;
+String variant = null;
int dash = entry.indexOf('-');
if (dash 0) {
language = entry;
country = ;
+variant = ;
} else {
language = entry.substring(0, dash);
country = entry.substring(dash + 1);
+int vDash = country.indexOf