You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "KARR, DAVID (ATTSI)" <dk...@att.com> on 2011/03/28 20:57:22 UTC
"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.
RE: "HttpHeaders.getAcceptableLanguages()" translates "en_us" to
"en_US"
Posted by "KARR, DAVID (ATTSI)" <dk...@att.com>.
> -----Original Message-----
> From: Sven Zethelius [mailto:svenz@expedia.com]
> Sent: Monday, March 28, 2011 12:43 PM
> To: users@cxf.apache.org
> Subject: RE: "HttpHeaders.getAcceptableLanguages()" translates "en_us"
> to "en_US"
>
> "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.
*whap* *whap*
Thanks.
> -----Original Message-----
> From: KARR, DAVID (ATTSI) [mailto:dk068x@att.com]
> Sent: Monday, March 28, 2011 12:29 PM
> To: users@cxf.apache.org
> 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: users@cxf.apache.org
> > 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.Local
> e.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.
RE: "HttpHeaders.getAcceptableLanguages()" translates "en_us" to
"en_US"
Posted by Sven Zethelius <sv...@expedia.com>.
"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:dk068x@att.com]
Sent: Monday, March 28, 2011 12:29 PM
To: users@cxf.apache.org
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: users@cxf.apache.org
> 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.
RE: "HttpHeaders.getAcceptableLanguages()" translates "en_us" to
"en_US"
Posted by "KARR, DAVID (ATTSI)" <dk...@att.com>.
> -----Original Message-----
> From: KARR, DAVID (ATTSI)
> Sent: Monday, March 28, 2011 11:57 AM
> To: users@cxf.apache.org
> 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.