users@jsr311.java.net

Re: Case-insensitive Response.getMetadata

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 28 Apr 2009 16:14:09 -0400

On Apr 28, 2009, at 2:48 PM, Sergey Beryozkin wrote:
>
> I’d like to confirm that MultivaluedMap<String, Object> instance
> returned by
> Response.getMetadata() is case-insensitive.
>
Its not required to be case-insensitive.

> Ex.
> MultivaluedMap<String, Object> headers =
> ResponseBuilder.ok().header(“Content-Type”, “text/
> xml”).build().getMetadata();
> assertNotNull(headers.getFirst(“content-type”));
>
> Is it correct ?
>
No. Maybe you are assuming it is the same as the map you get from
HttpHeaders.getRequestHeaders which is case insensitive ?

> If yes, then given that Response.getMetadata() is modifiable, what
> is the value of content type after
>
> headers.putSingle(“content-type”, “application/xml”);
>
> is it
>
> assertEquals(“application/xml”, headers.getFirst(“content-type”));
> assertEquals(“application/xml”, headers.getFirst(“Content-Type”));
>
> ?
>
> Another question :
>
> ResponseBuilder.ok().header(“Content-Type”, “text/
> xml”) .header(“content-type”, “text/plain”).build().get(“Content-
> Type”);
>
> Is it text/xml or text/plain or { text/xml , text/plain} ?
>
The builder isn't required to normalize case either, so I'd expect
text/xml and a malformed response with two content type headers.

Marc.