"en_US" is not a valid Accept-Language header.  It should be "en-US".  Since it 
is missing the "-", CXF parses it as language "en_US" instead of language "en", 
region "US", which is what Locale.US defined as.

-----Original Message-----
From: KARR, DAVID (ATTSI) [mailto:[email protected]] 
Sent: Monday, March 28, 2011 12:29 PM
To: [email protected]
Subject: RE: "HttpHeaders.getAcceptableLanguages()" translates "en_us" to 
"en_US"

> -----Original Message-----
> From: KARR, DAVID (ATTSI)
> Sent: Monday, March 28, 2011 11:57 AM
> To: [email protected]
> Subject: "HttpHeaders.getAcceptableLanguages()" translates "en_us" to
> "en_US"
> 
> I'm seeing a subtle problem in
> "javax.ws.rs.core.HttpHeaders.getAcceptableLanguages()".  It appears to
> be translating a header value of "en_US" to a Locale with a value of
> "en_us".  The problem is, the object "Locale.US" has a locale string of
> "en_US".  If I check to see if "Locale.US" is in my locale list, it
> fails to find it.

For some additional background, I send a "Accept-Language" header value of 
"en_US".

I have the following defined in my controller:

    @Context
    private HttpHeaders httpHeaders;

I have a getter for this.

If I execute this:

    getHttpHeaders().getAcceptableLanguages().get(0).equals(java.util.Locale.US)

this returns FALSE.

I first need to verify whether this is a bug, and in the meantime, figure out 
the most reasonable workaround for this.

Reply via email to